From ee53f39e9acfc255fd584c695ca4a23b9deb8511 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 10 Jul 2007 02:28:04 +0000 Subject: OK, this time I really fixed it so that it compares raw strings and FStrings the right way. --- src/fstring.h | 4 +++- src/unit/fstring.cpp | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/fstring.h b/src/fstring.h index fe3daf1..f52b6f1 100644 --- a/src/fstring.h +++ b/src/fstring.h @@ -399,10 +399,12 @@ namespace Bu flatten(); const chr *a = pData; chr *b = pFirst->pData; - for( long j = 0; *a!=(chr)0 && j < nLength; j++, a++, b++ ) + for( long j = 0; *a!=(chr)0 || *b!=(chr)0; j++, a++, b++ ) { if( *a != *b ) return false; + if( *a == (chr)0 && j < nLength ) + return false; } return true; diff --git a/src/unit/fstring.cpp b/src/unit/fstring.cpp index 72755eb..2c6bf7a 100644 --- a/src/unit/fstring.cpp +++ b/src/unit/fstring.cpp @@ -7,17 +7,26 @@ public: Unit() { setName("FString"); - addTest( Unit::test1 ); + addTest( Unit::compare1 ); + addTest( Unit::compare2 ); } virtual ~Unit() { } - void test1() + void compare1() { - unitTest( 1 == 1 ); - unitTest( 1 == 0 ); + Bu::FString b("Bob"); + unitTest( !(b == "Bobo") ); + unitTest( b == "Bob" ); + } + + void compare2() + { + Bu::FString b("Bobo"); + unitTest( !(b == "Bob") ); + unitTest( b == "Bobo" ); } }; -- cgit v1.2.3