From 5aec71241c874a2249c14025a7df1eddc1c14654 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 24 Sep 2008 03:45:46 +0000 Subject: Added a getSubStr function to Bu::FString, and more tests to the fstring unit test. --- src/unit/fstring.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/unit') diff --git a/src/unit/fstring.cpp b/src/unit/fstring.cpp index ea3342a..7be03a7 100644 --- a/src/unit/fstring.cpp +++ b/src/unit/fstring.cpp @@ -24,6 +24,8 @@ public: addTest( Unit::add2 ); addTest( Unit::add3 ); addTest( Unit::add4 ); + addTest( Unit::add5 ); + addTest( Unit::subStr1 ); } virtual ~Unit() @@ -128,6 +130,25 @@ public: unitTest( c == "hi there, yeah!" ); } + + void add5() + { + Bu::FString b; + Bu::FString c = "sup?"; + b += "hey, " + c; + + unitTest( b == "hey, sup?" ); + } + + void subStr1() + { + Bu::FString a("abcdefghijklmnop"); + unitTest( a.getSubStr( 5, 3 ) == "fgh" ); + unitTest( a.getSubStr( 10 ) == "klmnop" ); + unitTest( a.getSubStr( 40 ) == "" ); + unitTest( a.getSubStr( -10 ) == "abcdefghijklmnop" ); + unitTest( a.getSubStr( -15, 4 ) == "abcd" ); + } }; int main( int argc, char *argv[] ) -- cgit v1.2.3