2007-09-07 23:24:13 +02:00
|
|
|
/*
|
2018-10-03 04:43:16 +02:00
|
|
|
UtilSanitizedIdentifier(Test) - remove non-standard-chars and punctuation
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2008-03-10 04:25:03 +01:00
|
|
|
Copyright (C) Lumiera.org
|
|
|
|
|
2008, Hermann Vosseler <Ichthyostega@web.de>
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2007-09-07 23:24:13 +02:00
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License as
|
2010-12-17 23:28:49 +01:00
|
|
|
published by the Free Software Foundation; either version 2 of
|
|
|
|
|
the License, or (at your option) any later version.
|
|
|
|
|
|
2007-09-07 23:24:13 +02:00
|
|
|
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.
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2007-09-07 23:24:13 +02:00
|
|
|
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.
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2007-09-07 23:24:13 +02:00
|
|
|
* *****************************************************/
|
|
|
|
|
|
2018-10-03 04:43:16 +02:00
|
|
|
/** @file util-sanitised-identifier-test.cpp
|
|
|
|
|
** unit test \ref UtilSanitizedIdentifier_test
|
2016-11-03 18:20:10 +01:00
|
|
|
*/
|
|
|
|
|
|
2007-09-07 23:24:13 +02:00
|
|
|
|
2008-12-18 04:47:41 +01:00
|
|
|
#include "lib/test/run.hpp"
|
2023-09-26 02:32:48 +02:00
|
|
|
#include "lib/test/test-helper.hpp"
|
2008-12-18 04:47:41 +01:00
|
|
|
#include "lib/util.hpp"
|
2007-09-07 23:24:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
using std::cout;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-07-19 05:47:36 +02:00
|
|
|
namespace util {
|
|
|
|
|
namespace test {
|
2007-09-07 23:24:13 +02:00
|
|
|
|
2009-07-19 05:47:36 +02:00
|
|
|
|
2018-10-03 04:43:16 +02:00
|
|
|
class UtilSanitizedIdentifier_test : public Test
|
2009-07-19 05:47:36 +02:00
|
|
|
{
|
|
|
|
|
virtual void run (Arg)
|
2007-09-07 23:24:13 +02:00
|
|
|
{
|
2023-09-26 02:32:48 +02:00
|
|
|
CHECK (sanitise ( "Word") == "Word"_expect);
|
|
|
|
|
CHECK (sanitise ( "a Sentence") == "a_Sentence"_expect);
|
|
|
|
|
CHECK (sanitise ( "trailing Withespace\n \t") == "trailing_Withespace"_expect);
|
|
|
|
|
CHECK (sanitise ("with a \t lot\n of Whitespace") == "with_a_lot_of_Whitespace"_expect);
|
|
|
|
|
CHECK (sanitise ( "@with\".\'much ($punctuation)[]!") == "@with.much_($punctuation)"_expect);
|
|
|
|
|
CHECK (sanitise ( "§&Ω%€ leading garbage") == "leading_garbage"_expect);
|
|
|
|
|
CHECK (sanitise ( "mixed Ω garbage") == "mixed_garbage"_expect);
|
|
|
|
|
CHECK (sanitise ( "Bääääh!!") == "Bh"_expect);
|
|
|
|
|
CHECK (sanitise ( "§&Ω%€") == ""_expect);
|
2007-09-07 23:24:13 +02:00
|
|
|
}
|
2009-07-19 05:47:36 +02:00
|
|
|
};
|
|
|
|
|
|
2018-10-03 04:43:16 +02:00
|
|
|
LAUNCHER (UtilSanitizedIdentifier_test, "unit common");
|
2009-07-19 05:47:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
}} // namespace util::test
|
2007-09-07 23:24:13 +02:00
|
|
|
|