Newer
Older
#include "StringTest.h"
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( StringTest, "bits" );
CPPUNIT_TEST_SUITE_REGISTRATION( StringTest );
void StringTest::setUp() {
}
void StringTest::tearDown() {
}
void StringTest::testToString() {
CPPUNIT_ASSERT ( ext::to_string ( std::string ( "1" ) ) == "1" );
CPPUNIT_ASSERT ( ext::to_string ( 1 ) == "1" );
CPPUNIT_ASSERT ( ext::to_string ( 1ul ) == "1" );
CPPUNIT_ASSERT ( ext::to_string ( a ) == "" );
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
void StringTest::testExplode ( ) {
{
std::string one ( "a::bb::ccc" );
ext::vector < std::string > oneExploded = ext::explode ( one, "::" );
std::cout << oneExploded << std::endl;
CPPUNIT_ASSERT ( oneExploded.size ( ) == 3 );
CPPUNIT_ASSERT ( oneExploded [ 0 ] == "a" );
CPPUNIT_ASSERT ( oneExploded [ 1 ] == "bb" );
CPPUNIT_ASSERT ( oneExploded [ 2 ] == "ccc" );
}
{
std::string one ( "a::bb::ccc::" );
ext::vector < std::string > oneExploded = ext::explode ( one, "::" );
CPPUNIT_ASSERT ( oneExploded.size ( ) == 4 );
CPPUNIT_ASSERT ( oneExploded [ 0 ] == "a" );
CPPUNIT_ASSERT ( oneExploded [ 1 ] == "bb" );
CPPUNIT_ASSERT ( oneExploded [ 2 ] == "ccc" );
CPPUNIT_ASSERT ( oneExploded [ 3 ] == "" );
}
{
std::string one ( "" );
ext::vector < std::string > oneExploded = ext::explode ( one, "::" );
CPPUNIT_ASSERT ( oneExploded.size ( ) == 1 );
CPPUNIT_ASSERT ( oneExploded [ 0 ] == "" );
}
{
std::string one ( "::aa" );
ext::vector < std::string > oneExploded = ext::explode ( one, "::" );
std::cout << oneExploded << std::endl;
CPPUNIT_ASSERT ( oneExploded.size ( ) == 2 );
CPPUNIT_ASSERT ( oneExploded [ 0 ] == "" );
CPPUNIT_ASSERT ( oneExploded [ 1 ] == "aa" );
}
{
std::string one ( "::" );
ext::vector < std::string > oneExploded = ext::explode ( one, "::" );
CPPUNIT_ASSERT ( oneExploded.size ( ) == 2 );
CPPUNIT_ASSERT ( oneExploded [ 0 ] == "" );
CPPUNIT_ASSERT ( oneExploded [ 1 ] == "" );
}
}