Lumiera  0.pre.03
»edit your freedom«
query-text-test.cpp
Go to the documentation of this file.
1 /*
2  QueryText(Test) - verify syntactical query representation
3 
4  Copyright (C) Lumiera.org
5  2012, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 * *****************************************************/
22 
29 #include "lib/test/run.hpp"
30 #include "lib/query-util.hpp"
31 #include "lib/query-text.hpp"
32 #include "lib/util.hpp"
33 
34 #include <string>
35 //#include <map>
36 
37 using util::contains;
38 using util::isnil;
39 using std::string;
40 
41 namespace lib {
42 namespace test{
43 
44  namespace { // test fixture...
45 
46  } //(End) test fixture
47 
48 
49 
50 
51  /***************************************************************************/
58  class QueryText_test : public Test
59  {
60 
61  virtual void run (Arg)
62  {
63  emptyRepresentation();
64  build_from_string();
65  useHashValue();
66  }
67 
68 
69  void emptyRepresentation ()
70  {
71  QueryText noText;
72 
73  CHECK (isnil (noText));
74  CHECK (isnil (string(noText)));
75  }
76 
77 
78  void build_from_string ()
79  {
80  QueryText eternal ("beats(lumiera, duke_nukem_forever).");
81  CHECK (contains (string(eternal), "lumiera"));
82  CHECK (contains (string(eternal), "beats"));
83  CHECK (contains (string(eternal), "duke_nukem_forever"));
84  CHECK (eternal.hasAtom ("lumiera"));
85  }
86 
87 
88  void useHashValue ()
89  {
90  QueryText one("one");
91  QueryText two("two");
92 
93  CHECK (0 < hash_value(one));
94  CHECK (0 < hash_value(two));
95  CHECK (hash_value(one) != hash_value(two));
96  }
97 
98 
99  };
100 
101 
102 
104  LAUNCHER(QueryText_test, "unit common");
105 
106 }} // namespace lib::test
Utilities to support working with predicate queries.
Definition: run.hpp:49
A generic syntactical representation for all kinds of queries.
Implementation namespace for support and library code.
Simple 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:61
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:70
bool contains(SEQ const &cont, typename SEQ::const_reference val)
shortcut for brute-force containment test in any sequential container
Definition: util.hpp:255