diff options
Diffstat (limited to '')
| -rw-r--r-- | src/tests/confpair.cpp | 11 | ||||
| -rw-r--r-- | src/tests/hash.cpp | 77 |
2 files changed, 83 insertions, 5 deletions
diff --git a/src/tests/confpair.cpp b/src/tests/confpair.cpp index 8e03730..fb1b0d3 100644 --- a/src/tests/confpair.cpp +++ b/src/tests/confpair.cpp | |||
| @@ -5,10 +5,15 @@ using namespace std; | |||
| 5 | 5 | ||
| 6 | int main() | 6 | int main() |
| 7 | { | 7 | { |
| 8 | ConfPair<bool> p1("DebugMode"); | 8 | ConfPair<float> p1("DebugMode"); |
| 9 | p1.value() = true; | 9 | p1.value() = 12; |
| 10 | cout << p1.value() << "\n"; | 10 | cout << p1.value() << "\n"; |
| 11 | p1.value() = false; | 11 | p1.value() = 55; |
| 12 | cout << p1.value() << "\n"; | 12 | cout << p1.value() << "\n"; |
| 13 | |||
| 14 | ConfPairBase &p = p1; | ||
| 15 | |||
| 16 | p = "33.12"; | ||
| 17 | cout << p.getAsString(); | ||
| 13 | } | 18 | } |
| 14 | 19 | ||
diff --git a/src/tests/hash.cpp b/src/tests/hash.cpp index d0f5fa6..8406439 100644 --- a/src/tests/hash.cpp +++ b/src/tests/hash.cpp | |||
| @@ -3,8 +3,81 @@ | |||
| 3 | 3 | ||
| 4 | int main() | 4 | int main() |
| 5 | { | 5 | { |
| 6 | //Hash<class StaticString, int> sTest; | 6 | const char *names[]={ |
| 7 | "Homer the Great", | ||
| 8 | "And Maggie Makes Three", | ||
| 9 | "Bart's Comet", | ||
| 10 | "Homie The Clown", | ||
| 11 | "Bart Vs Australia", | ||
| 12 | "Homer vs Patty and Selma", | ||
| 13 | "A star is burns", | ||
| 14 | "Lisa's Wedding", | ||
| 15 | "Two Dozen and One Greyhounds", | ||
| 16 | "The PTA Disbands", | ||
| 17 | "Round Springfield", | ||
| 18 | "The Springfield connection", | ||
| 19 | "Lemon of Troy", | ||
| 20 | "Who Shot Mr. Burns (Pt. 1)", | ||
| 21 | "Who Shot Mr. Burns (pt. 2)", | ||
| 22 | "Radioactive Man", | ||
| 23 | "Home Sweet Homediddly-dum-doodly", | ||
| 24 | "Bart Sells His Soul", | ||
| 25 | "Lisa the Vegetarian", | ||
| 26 | "Treehouse of horror VI", | ||
| 27 | "King Size Homer", | ||
| 28 | "Mother Simpson", | ||
| 29 | "Sideshow Bob's Last Gleaming", | ||
| 30 | "The Simpson's 138th Show Spectacular", | ||
| 31 | "Marge Be Not Proud", | ||
| 32 | "Team Homer", | ||
| 33 | "Two Bad Neighbors", | ||
| 34 | "Scenes From the Class Struggle in Springfield", | ||
| 35 | "Bart the Fink", | ||
| 36 | "Lisa the Iconoclast", | ||
| 37 | "Homer the Smithers", | ||
| 38 | "The Day the Violence Died", | ||
| 39 | "A Fish Called Selma", | ||
| 40 | "Bart on the road", | ||
| 41 | "22 Short Films about Springfield", | ||
| 42 | "The Curse of the Flying Hellfish", | ||
| 43 | "Much Apu about Nothing", | ||
| 44 | "Homerpalooza", | ||
| 45 | "The Summer of 4 Ft 2", | ||
| 46 | "Treehouse of Horror VII", | ||
| 47 | "You Only Move Twice", | ||
| 48 | "The Homer They Fall", | ||
| 49 | "Burns Baby Burns", | ||
| 50 | "Bart After Dark", | ||
| 51 | "A Millhouse Divided", | ||
| 52 | "Lisas Date With Destiny", | ||
| 53 | "Hurricane Neddy", | ||
| 54 | "The Mysterious Voyage of Our Homer", | ||
| 55 | "The Springfield Files", | ||
| 56 | "The Twisted World of Marge Simpson", | ||
| 57 | "Mountain of Madness", | ||
| 58 | NULL | ||
| 59 | }; | ||
| 7 | 60 | ||
| 8 | //sTest.hasKey("hello"); | 61 | Hash<std::string, int> sTest; |
| 62 | |||
| 63 | printf("Inserting\n-------------------\n\n"); | ||
| 64 | for( int j = 0; j < 33; j++ ) | ||
| 65 | { | ||
| 66 | sTest[names[j]] = j; | ||
| 67 | } | ||
| 68 | |||
| 69 | printf("Getting\n-------------------\n\n"); | ||
| 70 | printf("%d\n", sTest.get( names[10] ) ); | ||
| 71 | printf("%d\n", (int)sTest[names[10]] ); | ||
| 72 | sTest[names[10]] = 22; | ||
| 73 | sTest["That one guy"] = 135; | ||
| 74 | printf("%d\n", (int)sTest[names[10]] ); | ||
| 75 | |||
| 76 | for( Hash<std::string, int>::iterator i = sTest.begin(); | ||
| 77 | i != sTest.end(); i++ ) | ||
| 78 | { | ||
| 79 | Hash<std::string, int>::iterator j = i; | ||
| 80 | printf("%d: %s\n", (*j).second, (*j).first.c_str() ); | ||
| 81 | } | ||
| 9 | } | 82 | } |
| 10 | 83 | ||
