Merged revisions 10129-10142 via svnmerge from
[wvapps.git] / funfs / tests / mrucachetest.cc
blob5fb59441ed5b9295a4ca82ef191b8449da6a824e
1 #include "wvmrucache.h"
2 #include "wvgdbmhash.h"
4 int main()
6 typedef WvMRUCache<WvString, datum, DatumCacheHelper> MyCache;
7 MyCache cache(5);
9 datum dummy;
10 dummy.dptr = (char *)10;
11 dummy.dsize = 0;
14 WvString silly("silly");
16 cache.add(silly, dummy);
18 silly = "foo";
20 cache.add(silly, dummy);
22 char *bar = "bar";
23 silly = bar;
25 cache.add(silly, dummy);
27 char *baz = "baz";
28 silly = baz;
30 cache.add(silly, dummy);
32 baz = "zig";
33 silly = baz;
35 cache.add(silly, dummy);
39 WvString silly("silly2");
41 cache.add(silly, dummy);
43 silly = "foo2";
45 cache.add(silly, dummy);
47 char *bar = "bar2";
48 silly = bar;
50 cache.add(silly, dummy);
52 char *baz = "baz2";
53 silly = baz;
55 cache.add(silly, dummy);
57 baz = "zig2";
58 silly = baz;
60 cache.add(silly, dummy);
63 assert(cache.maybe_get("zig2").dptr);
64 assert(cache.maybe_get("baz2").dptr);
65 assert(cache.maybe_get("bar2").dptr);
66 assert(cache.maybe_get("foo2").dptr);
67 assert(cache.maybe_get("silly2").dptr);
69 assert(!cache.maybe_get("foo").dptr);
70 assert(!cache.maybe_get("woo").dptr);
72 fprintf(stderr, "success\n");