Lumiera  0.pre.03
»edit your freedom«
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
query-text-test.cpp
Go to the documentation of this file.
1 /*
2  QueryText(Test) - verify syntactical query representation
3 
4  Copyright (C)
5  2012, Hermann Vosseler <Ichthyostega@web.de>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 * *****************************************************************/
13 
20 #include "lib/test/run.hpp"
21 #include "lib/query-util.hpp"
22 #include "lib/query-text.hpp"
23 #include "lib/util.hpp"
24 
25 #include <string>
26 //#include <map>
27 
28 using util::contains;
29 using util::isnil;
30 using std::string;
31 
32 namespace lib {
33 namespace test{
34 
35  namespace { // test fixture...
36 
37  } //(End) test fixture
38 
39 
40 
41 
42  /***************************************************************************/
49  class QueryText_test : public Test
50  {
51 
52  virtual void run (Arg)
53  {
54  emptyRepresentation();
55  build_from_string();
56  useHashValue();
57  }
58 
59 
60  void emptyRepresentation ()
61  {
62  QueryText noText;
63 
64  CHECK (isnil (noText));
65  CHECK (isnil (string(noText)));
66  }
67 
68 
69  void build_from_string ()
70  {
71  QueryText eternal ("beats(lumiera, duke_nukem_forever).");
72  CHECK (contains (string(eternal), "lumiera"));
73  CHECK (contains (string(eternal), "beats"));
74  CHECK (contains (string(eternal), "duke_nukem_forever"));
75  CHECK (eternal.hasAtom ("lumiera"));
76  }
77 
78 
79  void useHashValue ()
80  {
81  QueryText one("one");
82  QueryText two("two");
83 
84  CHECK (0 < hash_value(one));
85  CHECK (0 < hash_value(two));
86  CHECK (hash_value(one) != hash_value(two));
87  }
88 
89 
90  };
91 
92 
93 
95  LAUNCHER(QueryText_test, "unit common");
96 
97 }} // namespace lib::test
Utilities to support working with predicate queries.
Definition: run.hpp:40
A generic syntactical representation for all kinds of queries.
Implementation namespace for support and library code.
Simplistic test class runner.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
HashVal hash_value(QueryText const &entry)
support using queries in hashtables.
Definition: query-text.cpp:52
ExampleStrategy::Qualifier two(string additionalArg)
definition of another qualifier two(arg), accepting an additional argument
ExampleStrategy::Qualifier one()
definition of a qualifier one()
Syntactical query representation.
Definition: query-text.hpp:61
bool contains(SEQ const &cont, typename SEQ::const_reference val)
shortcut for brute-force containment test in any sequential container
Definition: util.hpp:255