00001 #ifndef STATIC_CONTIANER_TEST_TEST_STRING_H
00002
00003 #define STATIC_CONTIANER_TEST_TEST_STRING_H
00004
00005 #include <gslib/numeric.h>
00006
00008 template < typename StrGen >
00009 void test_string() {
00010 #define STR( len ) StrGen::gen< len >::type
00011 {
00012 STR( 15 ) empt;
00013 BOOST_CHECK( empt == "" );
00014 STR( 15 ) str = "hello world";
00015 BOOST_CHECK( "" != str );
00016 BOOST_CHECK( "hello world" == str );
00017 STR( 15 ) str2 = "hello world";
00018 BOOST_CHECK( str2 == str );
00019
00020
00021 str2 = str2;
00022 BOOST_CHECK( str2 == str );
00023
00024 str = "other string";
00025 BOOST_CHECK( "other string" == str );
00026
00027 STR( 20 ) otherSize( "my size is 20" );
00028 str = otherSize;
00029 BOOST_CHECK( str == "my size is 20" );
00030 STR( 15 ) str3( otherSize );
00031 BOOST_CHECK( str3 == "my size is 20" );
00032
00033
00034 str3 = "aaaaaaaaaaaaaaaaaaaa";
00035 BOOST_CHECK_MESSAGE( 15 == str3.size(), str3.c_str() );
00036 BOOST_CHECK( "aaaaaaaaaaaaaaaaaaaa" != str3 );
00037 }
00038 {
00039 STR( 20 ) a( "a" ), b( "b" ), c;
00040 c += a; c += b;
00041 BOOST_CHECK( "ab" == c );
00042
00043 a.pop_back();
00044 BOOST_CHECK( "" == a );
00045 a.clear();
00046 BOOST_CHECK( 0 == a.size() );
00047 b.clear();
00048 BOOST_CHECK( 0 == b.size() );
00049 b.append( a );
00050 BOOST_CHECK( 0 == b.size() );
00051 b.append( "append" );
00052 BOOST_CHECK( "append" == b );
00053 b += "append";
00054 BOOST_CHECK( "appendappend" == b );
00055 a += STR( 10 )( "abc" );
00056 BOOST_CHECK( "abc" == a );
00057 }
00058 #undef STR
00059 }
00060
00061 #endif