From c9574d3f77081fb4a654d42c298d6ebf34abca51 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 23 Nov 2007 23:47:37 +0000 Subject: Bu::FString now has insert and remove functions, yay! --- src/unit/fstring.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/unit') diff --git a/src/unit/fstring.cpp b/src/unit/fstring.cpp index 69c7e0a..03df9c3 100644 --- a/src/unit/fstring.cpp +++ b/src/unit/fstring.cpp @@ -18,6 +18,8 @@ public: addTest( Unit::compare2 ); addTest( Unit::appendSingle ); addTest( Unit::shared1 ); + addTest( Unit::insert ); + addTest( Unit::remove ); } virtual ~Unit() @@ -57,6 +59,34 @@ public: a = b; unitTest( a.getStr() == b.getStr() ); } + + void insert() + { + Bu::FString a("abcd"); + a.insert( 2, "-!-", 3 ); + unitTest( a == "ab-!-cd" ); + + a.insert( 0, "!!", 2 ); + unitTest( a == "!!ab-!-cd" ); + + a.insert( -10, "789", 3 ); + unitTest( a == "789!!ab-!-cd" ); + + a.insert( 12, "89", 2 ); + unitTest( a == "789!!ab-!-cd89" ); + + a.insert( 1203, "12", 2 ); + unitTest( a == "789!!ab-!-cd8912" ); + } + + void remove() + { + Bu::FString a("abHEYcd"); + a.remove( 2, 3 ); + unitTest( a == "abcd" ); + a.remove( 2, 5 ); + unitTest( a == "ab" ); + } }; int main( int argc, char *argv[] ) -- cgit v1.2.3