Lumiera  0.pre.03
»edit your freedom«
util-sanitised-identifier-test.cpp
Go to the documentation of this file.
1 /*
2  UtilSanitizedIdentifier(Test) - remove non-standard-chars and punctuation
3 
4  Copyright (C) Lumiera.org
5  2008, 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 
28 #include "lib/test/run.hpp"
29 #include "lib/test/test-helper.hpp"
30 #include "lib/util.hpp"
31 
32 
33 #include <iostream>
34 using std::cout;
35 
36 
37 
38 namespace util {
39 namespace test {
40 
41 
42  class UtilSanitizedIdentifier_test : public Test
43  {
44  virtual void run (Arg)
45  {
46  CHECK (sanitise ( "Word") == "Word"_expect);
47  CHECK (sanitise ( "a Sentence") == "a_Sentence"_expect);
48  CHECK (sanitise ( "trailing Withespace\n \t") == "trailing_Withespace"_expect);
49  CHECK (sanitise ("with a \t lot\n of Whitespace") == "with_a_lot_of_Whitespace"_expect);
50  CHECK (sanitise ( "@with\".\'much ($punctuation)[]!") == "@with.much_($punctuation)"_expect);
51  CHECK (sanitise ( "§&Ω%€ leading garbage") == "leading_garbage"_expect);
52  CHECK (sanitise ( "mixed Ω garbage") == "mixed_garbage"_expect);
53  CHECK (sanitise ( "Bääääh!!") == "Bh"_expect);
54  CHECK (sanitise ( "§&Ω%€") == ""_expect);
55  }
56  };
57 
58  LAUNCHER (UtilSanitizedIdentifier_test, "unit common");
59 
60 
61 }} // namespace util::test
62 
Definition: run.hpp:49
std::string sanitise(std::string const &)
produce an identifier based on the given string.
Definition: util.cpp:65
Simple test class runner.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
A collection of frequently used helper functions to support unit testing.