aboutsummaryrefslogtreecommitdiff
path: root/src/unit/array.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/unit/array.cpp35
1 files changed, 35 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
11class Unit : public Bu::UnitSuite 12class 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
62int main( int argc, char *argv[] ) 97int main( int argc, char *argv[] )