summaryrefslogtreecommitdiff
path: root/src/unit
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2008-10-08 16:17:26 +0000
committerMike Buland <eichlan@xagasoft.com>2008-10-08 16:17:26 +0000
commit3f1c8998166466245aee2860197fb4908e55f1a2 (patch)
treeb6d148679bbd87125f03cb723d5b59969b90c733 /src/unit
parent5883662909051e99093514483c32e2539a3cf850 (diff)
downloadlibbu++-3f1c8998166466245aee2860197fb4908e55f1a2.tar.gz
libbu++-3f1c8998166466245aee2860197fb4908e55f1a2.tar.bz2
libbu++-3f1c8998166466245aee2860197fb4908e55f1a2.tar.xz
libbu++-3f1c8998166466245aee2860197fb4908e55f1a2.zip
Ok...corrected a problem with new block allocation in nids, and it no longer
goes into an infinite loop while doing certain kinds of read. Also, it zeros out new blocks to make things easier to cope with in the hex editor, it'll probably also compress better. I also fixed Bu::MemBuf so that you can now write to arbitrary places mid-stream.
Diffstat (limited to 'src/unit')
-rw-r--r--src/unit/membuf.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/unit/membuf.cpp b/src/unit/membuf.cpp
index 3aebc4d..dc02aa3 100644
--- a/src/unit/membuf.cpp
+++ b/src/unit/membuf.cpp
@@ -15,6 +15,7 @@ public:
15 { 15 {
16 setName("MemBuf"); 16 setName("MemBuf");
17 addTest( Unit::testWriteRead01 ); 17 addTest( Unit::testWriteRead01 );
18 addTest( Unit::testOverwrite1 );
18 } 19 }
19 20
20 virtual ~Unit() 21 virtual ~Unit()
@@ -39,6 +40,21 @@ public:
39 unitTest( mb.read( buf, 7 ) == 3 ); 40 unitTest( mb.read( buf, 7 ) == 3 );
40 unitTest( !strncmp( buf, "eFG", 3 ) ); 41 unitTest( !strncmp( buf, "eFG", 3 ) );
41 } 42 }
43
44 void testOverwrite1()
45 {
46 Bu::MemBuf mb;
47 unitTest( mb.write("0123456789") == 10 );
48 mb.setPos( 4 );
49 unitTest( mb.write("-5-") == 3 );
50 mb.setPos( 9 );
51 mb.write("Hey!!!");
52 unitTest( mb.tell() == 15 );
53 char buf[50];
54 mb.setPos( 0 );
55 buf[mb.read( buf, 50 )] = '\0';
56 unitTest( !strcmp( buf, "0123-5-78Hey!!!" ) );
57 }
42}; 58};
43 59
44int main( int argc, char *argv[] ){ return Unit().run( argc, argv ); } 60int main( int argc, char *argv[] ){ return Unit().run( argc, argv ); }