diff options
author | Mike Buland <eichlan@xagasoft.com> | 2010-05-10 07:15:05 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2010-05-10 07:15:05 +0000 |
commit | 9731dc86fa9b12adc064b99910dddb58932c71cf (patch) | |
tree | 00a358ff397e2b7b0fc3377564288f5c86b850c5 /src/tests | |
parent | 8baf7e1e75a185c742dc6d5b27e50058635e5522 (diff) | |
download | libbu++-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 'src/tests')
-rw-r--r-- | src/tests/list2.cpp | 19 | ||||
-rw-r--r-- | src/tests/queuebuf.cpp | 42 |
2 files changed, 58 insertions, 3 deletions
diff --git a/src/tests/list2.cpp b/src/tests/list2.cpp new file mode 100644 index 0000000..cd02aef --- /dev/null +++ b/src/tests/list2.cpp | |||
@@ -0,0 +1,19 @@ | |||
1 | #include <bu/list.h> | ||
2 | #include <bu/sio.h> | ||
3 | |||
4 | using namespace Bu; | ||
5 | |||
6 | int main() | ||
7 | { | ||
8 | List<int64_t> lInt; | ||
9 | |||
10 | lInt.append( 512 ); | ||
11 | lInt.append( 1024 ); | ||
12 | lInt.append( 4096 ); | ||
13 | lInt.append( 12 ); | ||
14 | lInt.erase( 12 ); | ||
15 | lInt.append( 12 ); | ||
16 | lInt.erase( 12 ); | ||
17 | lInt.append( 12 ); | ||
18 | } | ||
19 | |||
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 | ||