Mercurial > dedupe
comparison TestDBCache.cpp @ 16:06166d6c083b
Add configuration processing.
Cache DB values
Add a custom RBTree to save space.
Track multiple DB connections properly.
More testing.
Add ValueExistsException.
| author | Tom Fredrik Blenning Klaussen <bfg@blenning.no> |
|---|---|
| date | Tue, 28 Aug 2012 18:58:02 +0200 |
| parents | |
| children | 1334d1417c0b |
comparison
equal
deleted
inserted
replaced
| 15:199fc63c60c1 | 16:06166d6c083b |
|---|---|
| 1 #include "DBCache.hpp" | |
| 2 #include "OrderedPair.hpp" | |
| 3 #include "TestFramework.hpp" | |
| 4 | |
| 5 #include <QtCore/QTemporaryFile> | |
| 6 | |
| 7 BOOST_AUTO_TEST_CASE( TestCache ) | |
| 8 { | |
| 9 QTemporaryFile sqlfile("XXXXXX.sqlite"); | |
| 10 sqlfile.setAutoRemove(false); | |
| 11 sqlfile.open(); | |
| 12 | |
| 13 typedef OrderedPair<QString> key_t; | |
| 14 | |
| 15 DBCache<key_t, int> cache (sqlfile.fileName(), "SomeLUT"); | |
| 16 key_t key1("hei", "hei"); | |
| 17 key_t key2("S'turday", "Sunday"); | |
| 18 | |
| 19 bool exists = cache.value(key1); | |
| 20 BOOST_REQUIRE_EQUAL(exists, false); | |
| 21 cache.insert(key1, 321); | |
| 22 BOOST_REQUIRE_EQUAL(cache.value(key1), 321); | |
| 23 | |
| 24 exists = cache.value(key2); | |
| 25 BOOST_REQUIRE_EQUAL(exists, false); | |
| 26 cache.insert(key2, 19); | |
| 27 BOOST_REQUIRE_EQUAL(cache.value(key2), 19); | |
| 28 | |
| 29 } |
