summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid <david@xagasoft.com>2008-12-30 22:07:47 +0000
committerDavid <david@xagasoft.com>2008-12-30 22:07:47 +0000
commitbbe8ee9de8bfbd490336d80e76148663dcbe027f (patch)
tree9a08a2ec412ba7a28e69cd8f844cd59dde97645a /src
parent1743bd0eacec94c6f6e3c89e16d0bd6d301017e8 (diff)
downloadlibbu++-bbe8ee9de8bfbd490336d80e76148663dcbe027f.tar.gz
libbu++-bbe8ee9de8bfbd490336d80e76148663dcbe027f.tar.bz2
libbu++-bbe8ee9de8bfbd490336d80e76148663dcbe027f.tar.xz
libbu++-bbe8ee9de8bfbd490336d80e76148663dcbe027f.zip
david - i found a strange hash bug, and made a unit test to reproduce it ("insert3")... with a hash of type Bu::Hash<int, Bu::FString>, when the size of the hash reaches certain points (11, 23, 46, 94, etc...), it seems to reset itself and not have any data in it...
Diffstat (limited to '')
-rw-r--r--src/unit/hash.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/unit/hash.cpp b/src/unit/hash.cpp
index 77160e3..1c873fd 100644
--- a/src/unit/hash.cpp
+++ b/src/unit/hash.cpp
@@ -16,6 +16,7 @@ class Unit : public Bu::UnitSuite
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; 18 typedef Bu::Hash<Bu::FString, Bu::FString> StrStrHash;
19 typedef Bu::Hash<int, Bu::FString> IntStrHash;
19 20
20public: 21public:
21 Unit() 22 Unit()
@@ -23,6 +24,7 @@ public:
23 setName("Hash"); 24 setName("Hash");
24 addTest( Unit::insert1 ); 25 addTest( Unit::insert1 );
25 addTest( Unit::insert2 ); 26 addTest( Unit::insert2 );
27 addTest( Unit::insert3 );
26 addTest( Unit::probe1 ); 28 addTest( Unit::probe1 );
27 addTest( Unit::erase1 ); 29 addTest( Unit::erase1 );
28 } 30 }
@@ -68,6 +70,17 @@ public:
68 unitTest( h3["Bye"].getValue() = "Later" ); 70 unitTest( h3["Bye"].getValue() = "Later" );
69 } 71 }
70 72
73 void insert3()
74 {
75 IntStrHash h;
76
77 for( unsigned int i=1; i<50; i++ )
78 {
79 h[i] = "testing";
80 unitTest( h.getSize() == i );
81 }
82 }
83
71 void erase1() 84 void erase1()
72 { 85 {
73 StrIntHash h; 86 StrIntHash h;