summaryrefslogtreecommitdiff
path: root/src/tests/rh.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-01-27 15:25:46 +0000
committerMike Buland <eichlan@xagasoft.com>2009-01-27 15:25:46 +0000
commit9098237f5bb16b204a5ea999b702e5eb170f68ac (patch)
treeddf0c3013f0877d1f406401c6b4509d11bfb23e3 /src/tests/rh.cpp
parent8bc5ac336d5d684341a05e97d1cb1b18ecba0331 (diff)
downloadlibbu++-9098237f5bb16b204a5ea999b702e5eb170f68ac.tar.gz
libbu++-9098237f5bb16b204a5ea999b702e5eb170f68ac.tar.bz2
libbu++-9098237f5bb16b204a5ea999b702e5eb170f68ac.tar.xz
libbu++-9098237f5bb16b204a5ea999b702e5eb170f68ac.zip
Corrected some larger read/write issues in corner cases that I hit suprisingly
often within nids. There's still a problem somewhere, but I'll find it. Also, even after having the file class canRead and canWrite functions work properly, and using them before trying to write to a nids to update info, we never ever write anything, so something is still wrong there. For now, all utilities that open a nids stream read-only will crash when it closes. Pretty minor really.
Diffstat (limited to '')
-rw-r--r--src/tests/rh.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/tests/rh.cpp b/src/tests/rh.cpp
new file mode 100644
index 0000000..70abcb7
--- /dev/null
+++ b/src/tests/rh.cpp
@@ -0,0 +1,52 @@
1#include "bu/file.h"
2#include "bu/hash.h"
3#include "bu/archive.h"
4#include "bu/fstring.h"
5#include "bu/nids.h"
6#include "bu/nidsstream.h"
7
8int main( int argc, char *argv[] )
9{
10 if( argv[1][0] == 'r' )
11 {
12 typedef Bu::Hash<Bu::FString, int> Hsh;
13
14 Bu::File fIn( argv[2], Bu::File::Read );
15 Bu::Archive ar( fIn, Bu::Archive::load );
16
17 Hsh h;
18 ar >> h;
19
20 printf("Read %d.\n", h.getSize() );
21 for( Hsh::iterator i = h.begin(); i != h.end(); i++ )
22 {
23 printf(" - \"%s\" = %d\n", i.getKey().getStr(), i.getValue() );
24 }
25
26 printf("%d vs. %d\n", h.getSize(), h.getKeys().getSize() );
27 }
28 else if( argv[1][0] == 'n' )
29 {
30 typedef Bu::Hash<Bu::FString, int> Hsh;
31
32 Bu::File fIn( argv[2], Bu::File::Read );
33 Bu::Nids n( fIn );
34 n.initialize();
35 Bu::NidsStream sIn = n.openStream( 0 );
36 Bu::Archive ar( sIn, Bu::Archive::load );
37
38 Hsh h;
39 ar >> h;
40
41 printf("Read %d.\n", h.getSize() );
42 for( Hsh::iterator i = h.begin(); i != h.end(); i++ )
43 {
44 printf(" - \"%s\" = %d\n", i.getKey().getStr(), i.getValue() );
45 }
46
47 printf("%d vs. %d\n", h.getSize(), h.getKeys().getSize() );
48 }
49
50 return 0;
51}
52