aboutsummaryrefslogtreecommitdiff
path: root/src/unit/hash.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2008-09-15 20:03:56 +0000
committerMike Buland <eichlan@xagasoft.com>2008-09-15 20:03:56 +0000
commit597a1487c716b799428f4b4a4903e65df4c93ba9 (patch)
treec743b0d4dfc3bacbffc196589543ec4e9abf1aaf /src/unit/hash.cpp
parent3c6cb7f2347aed974543f9082a0ccd297577db41 (diff)
downloadlibbu++-597a1487c716b799428f4b4a4903e65df4c93ba9.tar.gz
libbu++-597a1487c716b799428f4b4a4903e65df4c93ba9.tar.bz2
libbu++-597a1487c716b799428f4b4a4903e65df4c93ba9.tar.xz
libbu++-597a1487c716b799428f4b4a4903e65df4c93ba9.zip
Whoa! Loads of NIDS work. It actually compiles, runs, and I'm optimizing the
hell out of it. Good times, everyone. This is a major chunk for congo, and the new optimizations should be good.
Diffstat (limited to '')
-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[] )