CPPUNIT_ASSERT( s1 != neq2 );
CPPUNIT_ASSERT( s1 != neq3 );
CPPUNIT_ASSERT( s1 != neq4 );
+
+ CPPUNIT_ASSERT( wxString("\n").Cmp(" ") < 0 );
+ CPPUNIT_ASSERT( wxString("'").Cmp("!") > 0 );
+ CPPUNIT_ASSERT( wxString("!").Cmp("z") < 0 );
}
void StringTestCase::CompareNoCase()
CPPUNIT_CNCNEQ_ASSERT( s1, neq );
CPPUNIT_CNCNEQ_ASSERT( s1, neq2 );
CPPUNIT_CNCNEQ_ASSERT( s1, neq3 );
+
+ CPPUNIT_ASSERT( wxString("\n").CmpNoCase(" ") < 0 );
+ CPPUNIT_ASSERT( wxString("'").CmpNoCase("!") > 0);
+ CPPUNIT_ASSERT( wxString("!").Cmp("Z") < 0 );
}
void StringTestCase::Contains()
// NB: there are no standards about the minimum exponent width
// and newer MSVC versions use 3 digits as minimum exponent
// width while GNU libc uses 2 digits as minimum width...
-#ifdef __VISUALC__
+#ifdef wxUSING_VC_CRT_IO
{ -3e-10, "-3e-010" },
#else
{ -3e-10, "-3e-10" },
void StringTestCase::BeforeAndAfter()
{
- const wxString s(L"letter=\xe9;\xe7a=l\xe0");
+ // Construct a string with 2 equal signs in it by concatenating its three
+ // parts: before the first "=", in between the two "="s and after the last
+ // one. This allows to avoid duplicating the string contents (which has to
+ // be different for Unicode and ANSI builds) in the tests below.
+#if wxUSE_UNICODE
+ #define FIRST_PART L"letter"
+ #define MIDDLE_PART L"\xe9;\xe7a"
+ #define LAST_PART L"l\xe0"
+#else // !wxUSE_UNICODE
+ #define FIRST_PART "letter"
+ #define MIDDLE_PART "e;ca"
+ #define LAST_PART "la"
+#endif // wxUSE_UNICODE/!wxUSE_UNICODE
+
+ const wxString s(FIRST_PART wxT("=") MIDDLE_PART wxT("=") LAST_PART);
+
+ wxString r;
+
+ CPPUNIT_ASSERT_EQUAL( FIRST_PART, s.BeforeFirst('=', &r) );
+ CPPUNIT_ASSERT_EQUAL( MIDDLE_PART wxT("=") LAST_PART, r );
- CPPUNIT_ASSERT_EQUAL( "letter", s.BeforeFirst('=') );
- CPPUNIT_ASSERT_EQUAL( s, s.BeforeFirst('!') );
- CPPUNIT_ASSERT_EQUAL( L"letter=\xe9", s.BeforeFirst(';') );
+ CPPUNIT_ASSERT_EQUAL( s, s.BeforeFirst('!', &r) );
+ CPPUNIT_ASSERT_EQUAL( "", r );
- CPPUNIT_ASSERT_EQUAL( L"letter=\xe9;\xe7a", s.BeforeLast('=') );
- CPPUNIT_ASSERT_EQUAL( "", s.BeforeLast('!') );
- CPPUNIT_ASSERT_EQUAL( L"letter=\xe9", s.BeforeLast(';') );
- CPPUNIT_ASSERT_EQUAL( L"\xe9;\xe7a=l\xe0", s.AfterFirst('=') );
+ CPPUNIT_ASSERT_EQUAL( FIRST_PART wxT("=") MIDDLE_PART, s.BeforeLast('=', &r) );
+ CPPUNIT_ASSERT_EQUAL( LAST_PART, r );
+
+ CPPUNIT_ASSERT_EQUAL( "", s.BeforeLast('!', &r) );
+ CPPUNIT_ASSERT_EQUAL( s, r );
+
+
+ CPPUNIT_ASSERT_EQUAL( MIDDLE_PART wxT("=") LAST_PART, s.AfterFirst('=') );
CPPUNIT_ASSERT_EQUAL( "", s.AfterFirst('!') );
- CPPUNIT_ASSERT_EQUAL( L"\xe7a=l\xe0", s.AfterFirst(';') );
- CPPUNIT_ASSERT_EQUAL( L"l\xe0", s.AfterLast('=') );
+
+ CPPUNIT_ASSERT_EQUAL( LAST_PART, s.AfterLast('=') );
CPPUNIT_ASSERT_EQUAL( s, s.AfterLast('!') );
- CPPUNIT_ASSERT_EQUAL( L"\xe7a=l\xe0", s.AfterLast(';') );
+
+ #undef LAST_PART
+ #undef MIDDLE_PART
+ #undef FIRST_PART
}
void StringTestCase::ScopedBuffers()