/* QueryUtils(Test) - checking various utils provided for dealing with config queries Copyright (C) Lumiera.org 2008, Hermann Vosseler This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * *****************************************************/ #include "lib/test/run.hpp" #include "lib/util.hpp" #include "lib/util-foreach.hpp" #include "lib/query-util.hpp" #include "lib/cmdline.hpp" #include "query/querydiagnostics.hpp" #include #include using lib::Cmdline; using util::isnil; using util::contains; using util::for_each; using std::tr1::placeholders::_1; using std::tr1::bind; using std::string; using std::cout; using std::endl; namespace lib { namespace query { namespace test{ struct Thing { virtual ~Thing() {} // add RTTI for Query.asKey(); }; /************************************************************************ * @test check the various small helpers and utilities we utilise * for dealing with ConfigQuery */ class QueryUtils_test : public Test { virtual void run (Arg arg) { if (isnil(arg)) arg = Cmdline ("Query normaliseID extractID removeTerm countPred"); if (contains (arg, "Query" )) check_Query (); if (contains (arg, "normaliseID")) check_normaliseID(); if (contains (arg, "extractID" )) check_extractID (); if (contains (arg, "removeTerm" )) check_removeTerm (); if (contains (arg, "countPred" )) check_countPred (); } /** @test Query wrapper class basics */ void check_Query () { UNIMPLEMENTED ("generate a generic query key");////////////////////////////////////////////////////////////////////////////////////////////TODO // cout << Query ("I am writing a test sentence.").asKey() << endl;////////////////////////////////////////////////////////////////////////////////////////////TODO } /** @test sanitising and normalising various tokens */ void check_normaliseID () { Cmdline tokens ("a A AA dufte 1a _1 A_A BÄH"); tokens.push_back (""); tokens.push_back (" White \t space "); tokens.push_back ("§&Ω%€GΩ%€ar ☠☠☠ baäääääge!!!!! "); cout << "..original : " << tokens << " :"<