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)
5  2008, 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 
19 #include "lib/test/run.hpp"
20 #include "lib/test/test-helper.hpp"
21 #include "lib/util.hpp"
22 
23 
24 #include <iostream>
25 using std::cout;
26 
27 
28 
29 namespace util {
30 namespace test {
31 
32 
33  class UtilSanitizedIdentifier_test : public Test
34  {
35  virtual void run (Arg)
36  {
37  CHECK (sanitise ( "Word") == "Word"_expect);
38  CHECK (sanitise ( "a Sentence") == "a_Sentence"_expect);
39  CHECK (sanitise ( "trailing Withespace\n \t") == "trailing_Withespace"_expect);
40  CHECK (sanitise ("with a \t lot\n of Whitespace") == "with_a_lot_of_Whitespace"_expect);
41  CHECK (sanitise ( "@with\".\'much ($punctuation)[]!") == "@with.much_($punctuation)"_expect);
42  CHECK (sanitise ( "§&Ω%€ leading garbage") == "leading_garbage"_expect);
43  CHECK (sanitise ( "mixed Ω garbage") == "mixed_garbage"_expect);
44  CHECK (sanitise ( "Bääääh!!") == "Bh"_expect);
45  CHECK (sanitise ( "§&Ω%€") == ""_expect);
46  }
47  };
48 
49  LAUNCHER (UtilSanitizedIdentifier_test, "unit common");
50 
51 
52 }} // namespace util::test
53 
Definition: run.hpp:40
std::string sanitise(std::string const &)
produce an identifier based on the given string.
Definition: util.cpp:56
Simplistic 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.