diff options
Diffstat (limited to 'src/unit')
-rw-r--r-- | src/unit/array.cpp | 35 | ||||
-rw-r--r-- | src/unit/hash.cpp | 10 |
2 files changed, 45 insertions, 0 deletions
diff --git a/src/unit/array.cpp b/src/unit/array.cpp index 57d6c03..f7dc0ae 100644 --- a/src/unit/array.cpp +++ b/src/unit/array.cpp | |||
@@ -6,6 +6,7 @@ | |||
6 | */ | 6 | */ |
7 | 7 | ||
8 | #include "bu/unitsuite.h" | 8 | #include "bu/unitsuite.h" |
9 | #include "bu/hash.h" | ||
9 | #include "bu/array.h" | 10 | #include "bu/array.h" |
10 | 11 | ||
11 | class Unit : public Bu::UnitSuite | 12 | class Unit : public Bu::UnitSuite |
@@ -17,6 +18,7 @@ public: | |||
17 | addTest( Unit::general ); | 18 | addTest( Unit::general ); |
18 | addTest( Unit::iterate1 ); | 19 | addTest( Unit::iterate1 ); |
19 | addTest( Unit::iterate2 ); | 20 | addTest( Unit::iterate2 ); |
21 | addTest( Unit::copy ); | ||
20 | } | 22 | } |
21 | 23 | ||
22 | virtual ~Unit() | 24 | virtual ~Unit() |
@@ -57,6 +59,39 @@ public: | |||
57 | for( Bu::Array<int>::iterator i = ai.begin(); i != ai.end(); i++ ) | 59 | for( Bu::Array<int>::iterator i = ai.begin(); i != ai.end(); i++ ) |
58 | unitFailed("Empty lists shouldn't be iterated through."); | 60 | unitFailed("Empty lists shouldn't be iterated through."); |
59 | } | 61 | } |
62 | |||
63 | void copy() | ||
64 | { | ||
65 | typedef Bu::Hash<Bu::FString, Bu::FString> StrHash; | ||
66 | typedef Bu::Array<StrHash> StrHashArray; | ||
67 | |||
68 | StrHash h1; | ||
69 | h1["Hi"] = "Yo"; | ||
70 | h1["Bye"] = "Later"; | ||
71 | |||
72 | StrHash h2; | ||
73 | h2["Test"] = "Bloop"; | ||
74 | h2["Foo"] = "ooF"; | ||
75 | |||
76 | StrHashArray a1; | ||
77 | a1.append( h1 ); | ||
78 | a1.append( h2 ); | ||
79 | |||
80 | StrHashArray a2(a1); | ||
81 | |||
82 | unitTest( a2[0].get("Hi") == "Yo" ); | ||
83 | unitTest( a2[0].get("Bye") == "Later" ); | ||
84 | unitTest( a2[1].get("Test") == "Bloop" ); | ||
85 | unitTest( a2[1].get("Foo") == "ooF" ); | ||
86 | |||
87 | StrHashArray a3; | ||
88 | a3 = a1; | ||
89 | |||
90 | unitTest( a3[0].get("Hi") == "Yo" ); | ||
91 | unitTest( a3[0].get("Bye") == "Later" ); | ||
92 | unitTest( a3[1].get("Test") == "Bloop" ); | ||
93 | unitTest( a3[1].get("Foo") == "ooF" ); | ||
94 | } | ||
60 | }; | 95 | }; |
61 | 96 | ||
62 | int main( int argc, char *argv[] ) | 97 | int main( int argc, char *argv[] ) |
diff --git a/src/unit/hash.cpp b/src/unit/hash.cpp index b869bdd..de4edd1 100644 --- a/src/unit/hash.cpp +++ b/src/unit/hash.cpp | |||
@@ -54,7 +54,17 @@ public: | |||
54 | { | 54 | { |
55 | StrStrHash h; | 55 | StrStrHash h; |
56 | h["Hi"] = "Yo"; | 56 | h["Hi"] = "Yo"; |
57 | h["Bye"] = "Later"; | ||
57 | unitTest( h["Hi"].getValue() == "Yo" ); | 58 | unitTest( h["Hi"].getValue() == "Yo" ); |
59 | |||
60 | StrStrHash h2(h); | ||
61 | unitTest( h2["Hi"].getValue() = "Yo" ); | ||
62 | unitTest( h2["Bye"].getValue() = "Later" ); | ||
63 | |||
64 | StrStrHash h3; | ||
65 | h3 = h; | ||
66 | unitTest( h3["Hi"].getValue() = "Yo" ); | ||
67 | unitTest( h3["Bye"].getValue() = "Later" ); | ||
58 | } | 68 | } |
59 | }; | 69 | }; |
60 | 70 | ||