00001 #include "static_container/test/assert_new.h"
00002 #include <boost/test/minimal.hpp>
00003 #include "static_container/string.h"
00004 #include "static_container/test/dump.h"
00005
00006 using namespace static_container;
00007
00009 void test_basic() {
00010 string< 10 > s;
00011 BOOST_REQUIRE( s.empty() );
00012 BOOST_REQUIRE( 0 == s.size() );
00013 string< 10 > str( "hello" );
00014 BOOST_REQUIRE( "hello" == str );
00015 BOOST_REQUIRE( strlen( "hello" ) == str.size() );
00016 string< 12 > str2( "hello" );
00017 BOOST_REQUIRE( str2 == str );
00018 string< 15 > str3( str );
00019 str3 += str2;
00020 BOOST_REQUIRE( "hellohello" == str3 );
00021 str3.push_back( 'c' );
00022 BOOST_REQUIRE( "hellohelloc" == str3 );
00023 str3.pop_back();
00024 BOOST_REQUIRE( "hellohello" == str3 );
00025 str3.append( str2 );
00026 BOOST_REQUIRE( "hellohellohello" == str3 );
00027 }
00028
00030 void test_compare() {
00031 string< 10 > s, t;
00032 BOOST_REQUIRE( t == s );
00033 BOOST_REQUIRE( "" == s );
00034 BOOST_REQUIRE( "h" != s );
00035 BOOST_REQUIRE( s < "h" );
00036 BOOST_REQUIRE( false == ( s < t ) );
00037 s = "hello";
00038 BOOST_REQUIRE( "hello" == s );
00039 BOOST_REQUIRE( "hello" != t );
00040 t = "hellp";
00041 BOOST_REQUIRE( s < t );
00042 }
00043
00045 void test_dump() {
00046 string< 10 > s;
00047 test::dump( s );
00048 s = "hello";
00049 test::dump( s );
00050 s = "日本語";
00051 test::dump( s );
00052 }
00053
00054 int test_main( int argc, char* argv[] ) {
00055 test::begin();
00056 test_basic();
00057 test_compare();
00058 test_dump();
00059 return 0;
00060 }