From: Szasz P. <sp...@us...> - 2004-03-17 19:46:39
|
Update of /cvsroot/rtk/rtk/test/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23068/test/core Modified Files: array0.cpp debug0.cpp dict0.cpp dlist0.cpp error0.cpp string0.cpp variant0.cpp vector0.cpp Log Message: Some fixes to work in symbian Index: vector0.cpp =================================================================== RCS file: /cvsroot/rtk/rtk/test/core/vector0.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** vector0.cpp 28 Feb 2004 20:59:24 -0000 1.4 --- vector0.cpp 17 Mar 2004 19:37:08 -0000 1.5 *************** *** 22,25 **** --- 22,26 ---- typedef TVectorP<A*> VectorA; + typedef TVector<A> VectorA2; // A simple function to search a substring *************** *** 29,33 **** } ! typedef RCharVector::TSearchIterator<RCHAR*> Iter; int main(int argc, char* argv[]) --- 30,34 ---- } ! //typedef RCharVector::TSearchIterator<RCHAR*> Iter; int main(int argc, char* argv[]) *************** *** 75,78 **** --- 76,80 ---- STEP(PRINT(vc, "%s")); + /* OUT("Find first occurence of the substring 'ere': %d", vc.Find<RCHAR*>(FindSubStr, _R("ere"))); *************** *** 80,86 **** STEP(RCHAR* found); STEP(while (found = iter->Next()) rprintf(_R(" Found: %s\n"), found)); ! rprintf(_R("### Object vector ###\n")); ! STEP(VectorA * va = new VectorA()); STEP(va->Push(new A())); // A::A --- 82,89 ---- STEP(RCHAR* found); STEP(while (found = iter->Next()) rprintf(_R(" Found: %s\n"), found)); + */ ! rprintf(_R("### Object ptr vector ###\n")); ! { STEP(VectorA * va = new VectorA()); STEP(va->Push(new A())); // A::A *************** *** 93,96 **** --- 96,114 ---- STEP(delete va); // 1x A::~A (1 removed, 1 popped => 1 remained) STEP(delete tmp); // A::~A - let's not leave garbage + } + rprintf(_R("### Object vector ###\n")); + { + STEP(VectorA2 * va = new VectorA2()); + STEP(va->Push(A())); // A::A + STEP(va->Push(A())); // A::A + STEP(va->Push(A())); // A::A + STEP(va->Remove(-1)); // NOP: idx out of range + STEP(va->Remove(0)); // A::~A + STEP(A& tmp = va->Pop()); // NOP: object is popped, but not deleted + OUT("va->GetCount() = %d", va->GetCount()); + STEP(delete va); // 1x A::~A (1 removed, 1 popped => 1 remained) + } // A::~A - let's not leave garbage + + WAIT_KEY return 0; Index: array0.cpp =================================================================== RCS file: /cvsroot/rtk/rtk/test/core/array0.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** array0.cpp 22 Feb 2004 11:50:15 -0000 1.1 --- array0.cpp 17 Mar 2004 19:37:08 -0000 1.2 *************** *** 3,6 **** --- 3,8 ---- *****************************************************************************/ + #include "../test.h" + #ifdef _WIN32 #include <windows.h> *************** *** 25,29 **** --- 27,38 ---- } + #ifdef __EPOC32__ + // The Symbian devices have fewer memory :-( + // Altough they have more then 256K, so maybe there is problem with memory + // fragmentation + #define LARGESIZE 50000 + #else #define LARGESIZE 1000000 + #endif void large_test(bool prealloc) *************** *** 63,95 **** int main(int argc, char* argv[]) { ! IntArray ia; // Append some single values ! ia.Append(2); ! ia.Append(1); ! ia.Append(0); ! ia.Append(6); ! ia.Append(4); // Prepend int array int ints[] = {120,100,150}; ! ia.Prepend(ints, 3); // Print out: ! printf("Original order:\n"); print(&ia); ! printf("Ascending order:\n"); print(&ia, cmp_int_a); ! printf("Descending order:\n"); print(&ia, cmp_int_d); ! large_test(false); ! large_test(true); ! rprintf(_R("\nPress any key")); ! rgetchar(); return 0; --- 72,104 ---- int main(int argc, char* argv[]) { ! TITLE(_R("Test file for the Array class(es)")); ! STEP(IntArray ia); // Append some single values ! STEP(ia.Append(2)); ! STEP(ia.Append(1)); ! STEP(ia.Append(0)); ! STEP(ia.Append(6)); ! STEP(ia.Append(4)); // Prepend int array int ints[] = {120,100,150}; ! STEP(ia.Prepend(ints, 3)); // Print out: ! STEP(printf("Original order:\n")); print(&ia); ! STEP(printf("Ascending order:\n")); print(&ia, cmp_int_a); ! STEP(printf("Descending order:\n")); print(&ia, cmp_int_d); ! STEP(large_test(false)); ! STEP(large_test(true)); ! WAIT_KEY return 0; Index: dict0.cpp =================================================================== RCS file: /cvsroot/rtk/rtk/test/core/dict0.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** dict0.cpp 7 Mar 2004 20:53:00 -0000 1.8 --- dict0.cpp 17 Mar 2004 19:37:08 -0000 1.9 *************** *** 44,48 **** #include <rtk/Dict.h> #include <rtk/TDict.h> ! #include <rtk/Thread.h> #include "../test.h" --- 44,52 ---- #include <rtk/Dict.h> #include <rtk/TDict.h> ! ! /// \todo Replace this with a general condition about threads ! #ifndef __EPOC32__ ! # include <rtk/Thread.h> ! #endif #include "../test.h" *************** *** 190,193 **** --- 194,198 ---- int main(int argc, char** argv) { + TITLE(_R("Test file for Dict class(es)")); template_tests(); *************** *** 247,251 **** } ! getchar(); return 0; --- 252,256 ---- } ! WAIT_KEY return 0; Index: error0.cpp =================================================================== RCS file: /cvsroot/rtk/rtk/test/core/error0.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** error0.cpp 9 Mar 2004 17:01:29 -0000 1.3 --- error0.cpp 17 Mar 2004 19:37:08 -0000 1.4 *************** *** 15,19 **** } ! int main() { TITLE(_R("Example code for error handling in Rtk")); --- 15,19 ---- } ! int main(int argc, char * argv[]) { TITLE(_R("Example code for error handling in Rtk")); *************** *** 22,25 **** --- 22,28 ---- rprintf(_R("error caught: '%s' with error code %d\n"), error2str(ret), -ret); } + + WAIT_KEY + return 0; } Index: dlist0.cpp =================================================================== RCS file: /cvsroot/rtk/rtk/test/core/dlist0.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** dlist0.cpp 28 Feb 2004 20:59:24 -0000 1.2 --- dlist0.cpp 17 Mar 2004 19:37:08 -0000 1.3 *************** *** 11,15 **** IntIter* iter = list.GetIterator(); int v; ! while (v = iter->Next()) rprintf(_R(" %d"), v); rprintf(_R("\n")); --- 11,15 ---- IntIter* iter = list.GetIterator(); int v; ! while ((v = iter->Next())) rprintf(_R(" %d"), v); rprintf(_R("\n")); *************** *** 26,32 **** { rprintf(_R(" odds = ")); IntFilter* iter = list.GetFilter<int>(is_odd); int v; ! while (v = iter->Next()) rprintf(_R(" %d"), v); rprintf(_R("\n")); --- 26,37 ---- { rprintf(_R(" odds = ")); + #ifdef __EPOC32__ + // probably because Symbian uses an older gcc (< 3) + IntFilter* iter = list.GetFilter(is_odd); + #else IntFilter* iter = list.GetFilter<int>(is_odd); + #endif int v; ! while ((v = iter->Next())) rprintf(_R(" %d"), v); rprintf(_R("\n")); *************** *** 44,47 **** --- 49,53 ---- typedef DListP<A*> DListA; + /* if not used, let's comment it out ;-) // A simple function to search a substring static bool FindSubStr(RCHAR* str, RCHAR* sub) *************** *** 49,52 **** --- 55,59 ---- return (rstrstr(str, sub) != NULL); } + */ static bool fn_less(int a, int b) *************** *** 91,94 **** --- 98,103 ---- STEP(delete tmp); + WAIT_KEY + return 1; } Index: variant0.cpp =================================================================== RCS file: /cvsroot/rtk/rtk/test/core/variant0.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** variant0.cpp 18 Jan 2004 20:17:07 -0000 1.2 --- variant0.cpp 17 Mar 2004 19:37:08 -0000 1.3 *************** *** 1,15 **** ! #include <rtk/Variant.h> ! ! #define STEP(x) rprintf(_R("\n$ %s\n"), _R(#x));x ! #define OUT(msg,val) rprintf(_R("> ") _R(msg) _R("\n"), val) ! #define TITLE(x) \ ! rprintf(_R("-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-\n")); \ ! rprintf(_R(" %s\n"), _R(x)); \ ! rprintf(_R("-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-\n")); \ using namespace Rtk; ! int main() { TITLE("Example for the class Variant"); --- 1,9 ---- ! #include "../test.h" ! #include <rtk/Variant.h> using namespace Rtk; ! int main(int argc, char * argv[]) { TITLE("Example for the class Variant"); *************** *** 33,36 **** --- 27,32 ---- OUT("a.AsString() = '%s'\n", a.AsString().c_str()); + WAIT_KEY + return 0; } Index: string0.cpp =================================================================== RCS file: /cvsroot/rtk/rtk/test/core/string0.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** string0.cpp 9 Mar 2004 17:01:29 -0000 1.14 --- string0.cpp 17 Mar 2004 19:37:08 -0000 1.15 *************** *** 15,25 **** RCHAR source[] = { _R("A sample STRING") }; ! OUT("source = '%s'", source); STEP( rstrnset(source, '=', 5) ); ! OUT("source = '%s'", source); STEP( rstrset(source, '*') ); ! OUT("source = '%s'", source); } --- 15,25 ---- RCHAR source[] = { _R("A sample STRING") }; ! OUTD("source = '%s'", source); STEP( rstrnset(source, '=', 5) ); ! OUTD("source = '%s'", source); STEP( rstrset(source, '*') ); ! OUTD("source = '%s'", source); } *************** *** 31,41 **** RCHAR source2[] = { _R("A miXED-CAse StrinG") }; ! OUT("source = '%s'", source); STEP( rstrupr(source) ); ! OUT("source = '%s'", source); ! OUT("source2 = '%s'", source2); STEP( rstrlwr(source2) ); ! OUT("source2 = '%s'", source2); } --- 31,41 ---- RCHAR source2[] = { _R("A miXED-CAse StrinG") }; ! OUTD("source = '%s'", source); STEP( rstrupr(source) ); ! OUTD("source = '%s'", source); ! OUTD("source2 = '%s'", source2); STEP( rstrlwr(source2) ); ! OUTD("source2 = '%s'", source2); } *************** *** 48,60 **** RCHAR *search = _R(" "); ! OUT("source = '%s'", source); /* Token will point to "LINE". */ STEP(token = rstrtok_r(source, search, &sp)); ! OUT("token = '%s'", token); while(token) { STEP(token = rstrtok_r(NULL, search, &sp)); ! OUT("token = '%s'", token); } } --- 48,60 ---- RCHAR *search = _R(" "); ! OUTD("source = '%s'", source); /* Token will point to "LINE". */ STEP(token = rstrtok_r(source, search, &sp)); ! OUTD("token = '%s'", token); while(token) { STEP(token = rstrtok_r(NULL, search, &sp)); ! OUTD("token = '%s'", token); } } *************** *** 169,172 **** --- 169,174 ---- rstrtok_r_test(); + WAIT_KEY + return 0; } *************** *** 195,198 **** --- 197,201 ---- // printf like + #ifndef __EPOC32__ // to reduce the number of warnings rfprintf(0,0); rsnprintf(0,0,0); *************** *** 206,209 **** --- 209,213 ---- rsscanf(0,0); rscanf(0,0); + #endif // __EPOC32__ // File *************** *** 222,226 **** --- 226,232 ---- rstrcspn(0,0); rstrdup(0); + #ifndef __EPOC32__ // to reduce the number of warnings rstrftime(0,0,0,0); + #endif rstrlen(0); rstrncat(0,0,0); *************** *** 229,234 **** rstrpbrk(_R(""),0); rstrrchr(_R(""),0); ! rstrset(0,0); ! rstrnset(0,0,0); rstrspn(0,0); rstrstr(_R(""), _R("")); --- 235,240 ---- rstrpbrk(_R(""),0); rstrrchr(_R(""),0); ! rstrset(0,0); ! rstrnset(0,0,0); rstrspn(0,0); rstrstr(_R(""), _R("")); *************** *** 236,240 **** --- 242,248 ---- // is* + #ifndef __EPOC32__ // to reduce the number of warnings risascii(0); + #endif riscntrl(0); risgraph(0); Index: debug0.cpp =================================================================== RCS file: /cvsroot/rtk/rtk/test/core/debug0.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** debug0.cpp 21 Feb 2004 23:49:03 -0000 1.2 --- debug0.cpp 17 Mar 2004 19:37:08 -0000 1.3 *************** *** 1,5 **** - #include <rtk/debug.h> #include "../test.h" //// //// Define some debug handlers --- 1,6 ---- #include "../test.h" + #include <rtk/debug.h> + //// //// Define some debug handlers *************** *** 20,37 **** } ! int main() { TITLE(_R("Example code for the DEBUGing functionality of Rtk")); ! debug_add_cb(my_cb); ! debug_add_cb(my_cb2); ! DBG(0, D_ALL, _R("A very important message !")); ! DBG(2, D_ALL, _R("An important message!")); // the second handler shouldn't print this one: ! DBG(4, D_CORE, _R("You should know about this!")); // because the default DEBUG_LEVEL is 5, you should'nt see this one: ! DBG(6, D_ALL, _R("Am I boring ?")); return 0; } --- 21,40 ---- } ! int main(int argc, char* argv[]) { TITLE(_R("Example code for the DEBUGing functionality of Rtk")); ! STEP(debug_add_cb(my_cb)); ! STEP(debug_add_cb(my_cb2)); ! STEP(DBG(0, D_ALL, _R("A very important message !"))); ! STEP(DBG(2, D_ALL, _R("An important message!"))); // the second handler shouldn't print this one: ! STEP(DBG(4, D_CORE, _R("You should know about this!"))); // because the default DEBUG_LEVEL is 5, you should'nt see this one: ! STEP(DBG(6, D_ALL, _R("Am I boring ?"))); + WAIT_KEY + return 0; } |