aboutsummaryrefslogtreecommitdiff
path: root/src/unit
diff options
context:
space:
mode:
Diffstat (limited to 'src/unit')
-rw-r--r--src/unit/hash.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/unit/hash.cpp b/src/unit/hash.cpp
index 481256b..b869bdd 100644
--- a/src/unit/hash.cpp
+++ b/src/unit/hash.cpp
@@ -15,18 +15,22 @@ class Unit : public Bu::UnitSuite
15{ 15{
16private: 16private:
17 typedef Bu::Hash<Bu::FString, int> StrIntHash; 17 typedef Bu::Hash<Bu::FString, int> StrIntHash;
18 typedef Bu::Hash<Bu::FString, Bu::FString> StrStrHash;
19
18public: 20public:
19 Unit() 21 Unit()
20 { 22 {
21 setName("Hash"); 23 setName("Hash");
22 addTest( Unit::test_probe ); 24 addTest( Unit::insert1 );
25 addTest( Unit::insert2 );
26 addTest( Unit::probe1 );
23 } 27 }
24 28
25 virtual ~Unit() 29 virtual ~Unit()
26 { 30 {
27 } 31 }
28 32
29 void test_probe() 33 void probe1()
30 { 34 {
31 StrIntHash h; 35 StrIntHash h;
32 char buf[20]; 36 char buf[20];
@@ -38,6 +42,20 @@ public:
38 unitTest( h.has(sTmp) ); 42 unitTest( h.has(sTmp) );
39 } 43 }
40 } 44 }
45
46 void insert1()
47 {
48 StrIntHash h;
49 h["Hi"] = 42;
50 unitTest( h["Hi"] == 42 );
51 }
52
53 void insert2()
54 {
55 StrStrHash h;
56 h["Hi"] = "Yo";
57 unitTest( h["Hi"].getValue() == "Yo" );
58 }
41}; 59};
42 60
43int main( int argc, char *argv[] ) 61int main( int argc, char *argv[] )