00001 #include <spl/Debug.h> 00002 #include <spl/Log.h> 00003 #include <spl/text/StringTokenizer.h> 00004 00005 #ifdef DEBUG 00006 00007 static void _TestStringTokenizer1() 00008 { 00009 StringTokenizer st(String(" the time\thas\ncome\r,said ")); 00010 00011 DEBUG_CLEAR_MEM_CHECK_POINTS(); 00012 st.CheckMem(); 00013 DEBUG_DUMP_MEM_LEAKS(); 00014 UNIT_ASSERT_MEM_NOTED("StringTokenizer test 1.0"); 00015 00016 String tok; 00017 00018 UNIT_ASSERT("HasMoreTokens", st.HasMoreTokens()); 00019 st.NextToken(tok); 00020 UNIT_ASSERT("the", tok == "the"); 00021 00022 DEBUG_CLEAR_MEM_CHECK_POINTS(); 00023 st.CheckMem(); 00024 tok.CheckMem(); 00025 DEBUG_DUMP_MEM_LEAKS(); 00026 UNIT_ASSERT_MEM_NOTED("StringTokenizer test 1.1"); 00027 00028 UNIT_ASSERT("HasMoreTokens", st.HasMoreTokens()); 00029 st.NextToken(tok); 00030 UNIT_ASSERT("time", tok == "time"); 00031 00032 UNIT_ASSERT("HasMoreTokens", st.HasMoreTokens()); 00033 st.NextToken(tok); 00034 UNIT_ASSERT("has", tok == "has"); 00035 00036 UNIT_ASSERT("HasMoreTokens", st.HasMoreTokens()); 00037 st.NextToken(tok); 00038 UNIT_ASSERT("come", tok == "come"); 00039 00040 UNIT_ASSERT("HasMoreTokens", st.HasMoreTokens()); 00041 st.NextToken(tok); 00042 UNIT_ASSERT(",said", tok == ",said"); 00043 00044 UNIT_ASSERT("! HasMoreTokens", !st.HasMoreTokens()); 00045 00046 Log::SWriteOkFail( "StringTokenizer test 1" ); 00047 } 00048 00049 void _TestStringTokenizer() 00050 { 00051 _TestStringTokenizer1(); 00052 DEBUG_CLEAR_MEM_CHECK_POINTS(); 00053 DEBUG_DUMP_MEM_LEAKS(); 00054 } 00055 00056 #endif