summaryrefslogtreecommitdiff
path: root/cpp/test/Freeze/cursor/Client.cpp
diff options
context:
space:
mode:
authorMatthew Newhook <matthew@zeroc.com>2001-12-04 02:15:54 +0000
committerMatthew Newhook <matthew@zeroc.com>2001-12-04 02:15:54 +0000
commitf410bac4a0a79ae1e75594f958267e6296e359ee (patch)
tree4b4fb2b820b176731677b7b96174e31c43d93529 /cpp/test/Freeze/cursor/Client.cpp
parentgenerate Stream.java (diff)
downloadice-f410bac4a0a79ae1e75594f958267e6296e359ee.tar.bz2
ice-f410bac4a0a79ae1e75594f958267e6296e359ee.tar.xz
ice-f410bac4a0a79ae1e75594f958267e6296e359ee.zip
initial implementation of FreezeMap.
Diffstat (limited to 'cpp/test/Freeze/cursor/Client.cpp')
-rw-r--r--cpp/test/Freeze/cursor/Client.cpp94
1 files changed, 35 insertions, 59 deletions
diff --git a/cpp/test/Freeze/cursor/Client.cpp b/cpp/test/Freeze/cursor/Client.cpp
index 08b8ffdc63a..c3cd179fb12 100644
--- a/cpp/test/Freeze/cursor/Client.cpp
+++ b/cpp/test/Freeze/cursor/Client.cpp
@@ -126,37 +126,40 @@ run(int argc, char* argv[], const DBEnvironmentPtr& dbEnv)
j = alphabet.begin();
try
{
- while(cursor->hasNext())
+ do
{
- cursor->next(k, v);
+ cursor->curr(k, v);
readValue(db, k, v, key, value);
test(key == *j && value == j - alphabet.begin());
++j;
}
+ while (cursor->next());
}
catch(const DBNotFoundException&)
{
+ test(false);
}
cursor->close();
cout << "ok" << endl;
- cout << "Testing DB::getCursorForKey... ";
+ cout << "Testing DB::getCursorAKey... ";
k = KeyCodec::write('n', instance);
j = find(alphabet.begin(), alphabet.end(), 'n');
- cursor = db->getCursorForKey(k);
+ cursor = db->getCursorAtKey(k);
try
{
-
- while(cursor->hasNext())
+ do
{
- cursor->next(k, v);
+ cursor->curr(k, v);
readValue(db, k, v, key, value);
test(key == *j && value == j - alphabet.begin());
++j;
}
+ while (cursor->next());
}
catch(const DBNotFoundException&)
{
+ test(false);
}
cursor->close();
cout << "ok" << endl;
@@ -167,30 +170,21 @@ run(int argc, char* argv[], const DBEnvironmentPtr& dbEnv)
try
{
- cursor->remove();
- test(false);
- }
- catch(const DBNotFoundException&)
- {
- // Ignore expected exception
- }
-
- try
- {
-
- while(cursor->hasNext())
+ do
{
- cursor->next(k, v);
+ cursor->curr(k, v);
readValue(db, k, v, key, value);
test(key == *j && value == j - alphabet.begin());
- cursor->remove();
+ cursor->del();
++j;
if (key == 'c')
break;
}
+ while (cursor->next());
}
catch(const DBNotFoundException&)
{
+ test(false);
}
cursor->close();
@@ -198,13 +192,14 @@ run(int argc, char* argv[], const DBEnvironmentPtr& dbEnv)
j = find(alphabet.begin(), alphabet.end(), 'd');
try
{
- while(cursor->hasNext())
+ do
{
- cursor->next(k, v);
+ cursor->curr(k, v);
readValue(db, k, v, key, value);
test(key == *j && value == j - alphabet.begin());
++j;
}
+ while (cursor->next());
}
catch(const DBNotFoundException&)
{
@@ -215,11 +210,11 @@ run(int argc, char* argv[], const DBEnvironmentPtr& dbEnv)
//
// Get a cursor for the deleted element - this should fail.
//
- cout << "Testing DB::getCursorForKey (again)... ";
+ cout << "Testing DB::getCursorAtKey (again)... ";
try
{
k = KeyCodec::write('a', instance);
- cursor = db->getCursorForKey(k);
+ cursor = db->getCursorAtKey(k);
test(false);
}
catch(const DBNotFoundException&)
@@ -235,11 +230,11 @@ run(int argc, char* argv[], const DBEnvironmentPtr& dbEnv)
//
// Verify both cursors point at 'd'
//
- cursor->next(k, v);
+ cursor->curr(k, v);
readValue(db, k, v, key, value);
test(key == 'd' && value == 3);
- clone->next(k, v);
+ clone->curr(k, v);
readValue(db, k, v, key, value);
test(key == 'd' && value == 3);
@@ -250,17 +245,17 @@ run(int argc, char* argv[], const DBEnvironmentPtr& dbEnv)
// Create cursor that points at 'n'
//
k = KeyCodec::write('n', instance);
- cursor = db->getCursorForKey(k);
+ cursor = db->getCursorAtKey(k);
clone = cursor->clone();
//
// Verify both cursors point at 'n'
//
- cursor->next(k, v);
+ cursor->curr(k, v);
readValue(db, k, v, key, value);
test(key == 'n' && value == 13);
- clone->next(k, v);
+ clone->curr(k, v);
readValue(db, k, v, key, value);
test(key == 'n' && value == 13);
@@ -271,8 +266,9 @@ run(int argc, char* argv[], const DBEnvironmentPtr& dbEnv)
// Create cursor that points at 'n'
//
k = KeyCodec::write('n', instance);
- cursor = db->getCursorForKey(k);
- cursor->next(k, v);
+ cursor = db->getCursorAtKey(k);
+ cursor->curr(k, v);
+ cursor->next();
readValue(db, k, v, key, value);
test(key == 'n' && value == 13);
@@ -281,44 +277,24 @@ run(int argc, char* argv[], const DBEnvironmentPtr& dbEnv)
//
// Verify cloned cursors are independent
//
- cursor->next(k, v);
+ cursor->curr(k, v);
+ cursor->next();
readValue(db, k, v, key, value);
test(key == 'o' && value == 14);
- cursor->next(k, v);
+ cursor->curr(k, v);
+ cursor->next();
readValue(db, k, v, key, value);
test(key == 'p' && value == 15);
- clone->next(k, v);
+ clone->curr(k, v);
+ clone->next();
readValue(db, k, v, key, value);
test(key == 'o' && value == 14);
cursor->close();
clone->close();
-
- cursor = db->getCursor();
-
- clone = cursor->clone();
-
- //
- // Get the 'd' value
- //
- cursor->next(k, v);
- readValue(db, k, v, key, value);
- test(key == 'd' && value == 3);
-
- //
- // Clone the cursor
- //
- cursor->remove();
-
- clone->next(k, v);
- readValue(db, k, v, key, value);
- test(key == 'e' && value == 4);
-
- clone->close();
- cursor->close();
-
+
cout << " ok" << endl;
db->close();