#include <gslib/numeric.h>Include dependency graph for test_string.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Defines | |
| #define | STR(len) StrGen::gen< len >::type |
Functions | |
| template<typename StrGen> void | test_string () |
| 文字列の基本テスト | |
|
|
Referenced by test_string(). |
|
|||||||||
|
文字列の基本テスト
Definition at line 9 of file test_string.h. References STR.
00009 {
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 }
|
1.3.6