diff options
Diffstat (limited to 'cpp/test')
-rw-r--r-- | cpp/test/Freeze/complex/Client.cpp | 2 | ||||
-rw-r--r-- | cpp/test/Freeze/complex/Complex.ice | 18 | ||||
-rw-r--r-- | cpp/test/Freeze/cursor/Client.cpp | 17 | ||||
-rw-r--r-- | cpp/test/Freeze/dbmap/Client.cpp | 24 |
4 files changed, 39 insertions, 22 deletions
diff --git a/cpp/test/Freeze/complex/Client.cpp b/cpp/test/Freeze/complex/Client.cpp index e120644497a..faafbca2966 100644 --- a/cpp/test/Freeze/complex/Client.cpp +++ b/cpp/test/Freeze/complex/Client.cpp @@ -36,7 +36,7 @@ validate(const DBPtr& db) for (p = m.begin(); p != m.end(); ++p) { // - // Verified the stored record is correct. + // Verify the stored record is correct. // test(p->first.result == p->second->calc()); diff --git a/cpp/test/Freeze/complex/Complex.ice b/cpp/test/Freeze/complex/Complex.ice index 44bb0e500c3..4a69236d237 100644 --- a/cpp/test/Freeze/complex/Complex.ice +++ b/cpp/test/Freeze/complex/Complex.ice @@ -15,7 +15,7 @@ module Complex // The database key (the expression and the result). Naturally, this // is a stupid key - but this is only a test :) // -/*local*/ struct Key +struct Key { string expression; int result; @@ -24,33 +24,27 @@ module Complex // // A set of classes that represents a numeric parse tree. // -/*local*/ class Node { +class Node { int calc(); }; -/*local*/ class NumberNode extends Node +class NumberNode extends Node { - int calc(); - int _number; }; -/*local*/ class BinaryNode extends Node +class BinaryNode extends Node { - int calc(); - Node _left; Node _right; }; -/*local*/ class AddNode extends BinaryNode +class AddNode extends BinaryNode { - int calc(); }; -/*local*/ class MultiplyNode extends BinaryNode +class MultiplyNode extends BinaryNode { - int calc(); }; }; diff --git a/cpp/test/Freeze/cursor/Client.cpp b/cpp/test/Freeze/cursor/Client.cpp index 79ecd512782..1bd50da5e54 100644 --- a/cpp/test/Freeze/cursor/Client.cpp +++ b/cpp/test/Freeze/cursor/Client.cpp @@ -142,6 +142,23 @@ run(int argc, char* argv[], const DBEnvironmentPtr& dbEnv) cursor->close(); cout << "ok" << endl; + cout << "testing contains... "; + try + { + for (j = alphabet.begin(); j != alphabet.end(); ++j) + { + k = KeyCodec::write(*j, instance); + test(db->contains(k)); + } + } + catch(const DBException&) + { + test(false); + } + k = KeyCodec::write('0', instance); + test(!db->contains(k)); + cout << "ok" << endl; + cout << "testing DB::getCursorAtKey... "; k = KeyCodec::write('n', instance); j = find(alphabet.begin(), alphabet.end(), 'n'); diff --git a/cpp/test/Freeze/dbmap/Client.cpp b/cpp/test/Freeze/dbmap/Client.cpp index f249c6cc237..7f4f9b0eb0e 100644 --- a/cpp/test/Freeze/dbmap/Client.cpp +++ b/cpp/test/Freeze/dbmap/Client.cpp @@ -126,6 +126,9 @@ run(int argc, char* argv[], const DBPtr& db) test(cp != m.end()); test(cp->first == *j && cp->second == j - alphabet.begin()); } + + test(!m.empty()); + test(m.size() == alphabet.size()); cout << "ok" << endl; cout << "testing map::find... "; @@ -182,10 +185,11 @@ run(int argc, char* argv[], const DBPtr& db) CharIntMap::iterator p2 = p; // - // Verify both iterators point at 'd' + // Verify both iterators point at the same element, and that + // element is in the map. // - test(p->first == 'd' && p->second == 3); - test(p2->first == 'd' && p2->second == 3); + test(p->first == p2->first && p->second == p2->second); + test(find(alphabet.begin(), alphabet.end(), p->first) != alphabet.end()); // // Create iterator that points at 'n' @@ -222,22 +226,24 @@ run(int argc, char* argv[], const DBPtr& db) cout << "ok" << endl; - cout << "testing operator[]... "; + // + // Test writing into an iterator. + // + cout << "testing iterator.set... "; + p = m.find('d'); test(p != m.end() && p->second == 3); + test(m.find('a') == m.end()); m.insert(CharIntMap::value_type('a', 1)); + p = m.find('a'); test(p != m.end() && p->second == 1); + m.insert(CharIntMap::value_type('a', 0)); p = m.find('a'); test(p != m.end() && p->second == 0); - cout << "ok" << endl; - // - // Test writing into an iterator. - // - cout << "testing iterator.set... "; p = m.find('a'); test(p != m.end() && p->second == 0); p.set(1); |