1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifndef UT_MISC_SSTRING
18 #define UT_MISC_SSTRING
20 #include <nel/misc/sstring.h>
22 struct CUTMiscSString
: public Test::Suite
26 TEST_ADD(CUTMiscSString::testStrtok
);
27 // Add a line here when adding a new test METHOD
32 NLMISC::CSString
testLine(" a=b c (a=e b=c) \t\t c(a=e b=c) toto(bimbo(foo(bar(a=b))))");
34 NLMISC::CSString part
;
35 part
= testLine
.strtok(" \t", true, false);
36 TEST_ASSERT(part
== "a=b");
37 part
= testLine
.strtok(" \t", true, false);
38 TEST_ASSERT(part
== "c");
39 part
= testLine
.strtok(" \t", true, false);
40 TEST_ASSERT(part
== "(a=e b=c)");
41 part
= testLine
.strtok(" \t", true, false);
42 TEST_ASSERT(part
== "c");
43 part
= testLine
.strtok(" \t=", true, false);
44 TEST_ASSERT(part
== "(a=e b=c)");
45 part
= testLine
.strtok(" \t=", true, false);
46 TEST_ASSERT(part
== "toto");
47 part
= testLine
.strtok(" \t=", true, false);
48 TEST_ASSERT(part
== "(bimbo(foo(bar(a=b))))");
49 part
= part
.stripBlockDelimiters();
50 NLMISC::CSString part2
= part
.strtok(" \t=", true, false);
51 TEST_ASSERT(part2
== "bimbo");
52 part2
= part
.strtok(" \t=", true, false);
53 TEST_ASSERT(part2
== "(foo(bar(a=b)))");