From 9731dc86fa9b12adc064b99910dddb58932c71cf Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 10 May 2010 07:15:05 +0000 Subject: 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. --- src/tests/queuebuf.cpp | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) (limited to 'src/tests/queuebuf.cpp') 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() qb.write( src, 60 ); } - char buf[11]; + char buf[11], bufp[11]; while( !qb.isEos() ) { - buf[qb.read( buf, 9 )] = '\0'; - sio << "Read: >>" << buf << "<<" << sio.nl; + int iAmntPeek = qb.peek( bufp, 9 ); + int iAmntRead = qb.read( buf, 9 ); + if( iAmntPeek != iAmntRead ) + sio << "Differ: " << iAmntPeek << " vs " << iAmntRead << sio.nl; + buf[iAmntRead] = '\0'; + bufp[iAmntPeek] = '\0'; + if( memcmp( buf, bufp, iAmntPeek ) ) + { + sio << "Buffers differ" << sio.nl + << " " << buf << sio.nl + << " " << bufp << sio.nl; + } + else + sio << "Read: >>" << buf << "<<" << sio.nl; + } + + sio << sio.nl << sio.nl << sio.nl << "Seek test:" << sio.nl << sio.nl; + + for( int j = 0; j < 5; j++ ) + { + qb.write( src, 25 ); + qb.write( src+10, 25 ); + } + + char bufa[26]; + char bufb[26]; + ::memcpy( bufb, src+10, 15 ); + ::memcpy( bufb+15, src+10, 10 ); + bufb[25] = '\0'; + sio << "Comparing to '" << bufb << "'" << sio.nl; + qb.seek( 10 ); + while( !qb.isEos() ) + { + bufa[qb.read( bufa, 25 )] = '\0'; + qb.seek( 25 ); + if( memcmp( bufa, bufb, 25 ) ) + sio << "Differ?" << sio.nl; + sio << "=== '" << bufa << "' == '" << bufb << "'" << sio.nl; } } -- cgit v1.2.3