aboutsummaryrefslogtreecommitdiff
path: root/src/tests/queuebuf.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2010-05-10 07:15:05 +0000
committerMike Buland <eichlan@xagasoft.com>2010-05-10 07:15:05 +0000
commit9731dc86fa9b12adc064b99910dddb58932c71cf (patch)
tree00a358ff397e2b7b0fc3377564288f5c86b850c5 /src/tests/queuebuf.cpp
parent8baf7e1e75a185c742dc6d5b27e50058635e5522 (diff)
downloadlibbu++-9731dc86fa9b12adc064b99910dddb58932c71cf.tar.gz
libbu++-9731dc86fa9b12adc064b99910dddb58932c71cf.tar.bz2
libbu++-9731dc86fa9b12adc064b99910dddb58932c71cf.tar.xz
libbu++-9731dc86fa9b12adc064b99910dddb58932c71cf.zip
Added the new Bu::CacheStoreFiles, it's an uber-simple cache storage system that
maybe would be better to call an example than a fully fledged storage strategy. It just names files based on your keys. It's very slow, and very wasteful, and shouldn't be used long-term in most normal cache systems.
Diffstat (limited to '')
-rw-r--r--src/tests/queuebuf.cpp42
1 files changed, 39 insertions, 3 deletions
diff --git a/src/tests/queuebuf.cpp b/src/tests/queuebuf.cpp
index accc723..677df16 100644
--- a/src/tests/queuebuf.cpp
+++ b/src/tests/queuebuf.cpp
@@ -13,11 +13,47 @@ int main()
13 qb.write( src, 60 ); 13 qb.write( src, 60 );
14 } 14 }
15 15
16 char buf[11]; 16 char buf[11], bufp[11];
17 while( !qb.isEos() ) 17 while( !qb.isEos() )
18 { 18 {
19 buf[qb.read( buf, 9 )] = '\0'; 19 int iAmntPeek = qb.peek( bufp, 9 );
20 sio << "Read: >>" << buf << "<<" << sio.nl; 20 int iAmntRead = qb.read( buf, 9 );
21 if( iAmntPeek != iAmntRead )
22 sio << "Differ: " << iAmntPeek << " vs " << iAmntRead << sio.nl;
23 buf[iAmntRead] = '\0';
24 bufp[iAmntPeek] = '\0';
25 if( memcmp( buf, bufp, iAmntPeek ) )
26 {
27 sio << "Buffers differ" << sio.nl
28 << " " << buf << sio.nl
29 << " " << bufp << sio.nl;
30 }
31 else
32 sio << "Read: >>" << buf << "<<" << sio.nl;
33 }
34
35 sio << sio.nl << sio.nl << sio.nl << "Seek test:" << sio.nl << sio.nl;
36
37 for( int j = 0; j < 5; j++ )
38 {
39 qb.write( src, 25 );
40 qb.write( src+10, 25 );
41 }
42
43 char bufa[26];
44 char bufb[26];
45 ::memcpy( bufb, src+10, 15 );
46 ::memcpy( bufb+15, src+10, 10 );
47 bufb[25] = '\0';
48 sio << "Comparing to '" << bufb << "'" << sio.nl;
49 qb.seek( 10 );
50 while( !qb.isEos() )
51 {
52 bufa[qb.read( bufa, 25 )] = '\0';
53 qb.seek( 25 );
54 if( memcmp( bufa, bufb, 25 ) )
55 sio << "Differ?" << sio.nl;
56 sio << "=== '" << bufa << "' == '" << bufb << "'" << sio.nl;
21 } 57 }
22} 58}
23 59