summaryrefslogtreecommitdiff
path: root/cpp/test/Freeze/dbmap/Client.cpp
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2005-04-15 21:26:47 +0000
committerBernard Normier <bernard@zeroc.com>2005-04-15 21:26:47 +0000
commitd0ba4d91861398071518fcd74b8573da081855f2 (patch)
tree320a475604d2df96f49ecdea0f26eb6dcc13e029 /cpp/test/Freeze/dbmap/Client.cpp
parentminor edits (diff)
downloadice-d0ba4d91861398071518fcd74b8573da081855f2.tar.bz2
ice-d0ba4d91861398071518fcd74b8573da081855f2.tar.xz
ice-d0ba4d91861398071518fcd74b8573da081855f2.zip
Merged Freeze Map index fix from 2.1
Diffstat (limited to 'cpp/test/Freeze/dbmap/Client.cpp')
-rw-r--r--cpp/test/Freeze/dbmap/Client.cpp65
1 files changed, 64 insertions, 1 deletions
diff --git a/cpp/test/Freeze/dbmap/Client.cpp b/cpp/test/Freeze/dbmap/Client.cpp
index 6e693b1a357..d2235fb5870 100644
--- a/cpp/test/Freeze/dbmap/Client.cpp
+++ b/cpp/test/Freeze/dbmap/Client.cpp
@@ -11,6 +11,8 @@
#include <Freeze/Freeze.h>
#include <TestCommon.h>
#include <ByteIntMap.h>
+#include <IntIdentityMap.h>
+#include <IntIdentityMapWithIndex.h>
#include <Freeze/TransactionHolder.h>
#include <algorithm>
@@ -197,7 +199,7 @@ private:
int
-run(const CommunicatorPtr& communicator, const string& envName, const string&dbName)
+run(const CommunicatorPtr& communicator, const string& envName, const string& dbName)
{
Freeze::ConnectionPtr connection = createConnection(communicator, envName);
ByteIntMap m(connection, dbName);
@@ -557,6 +559,67 @@ run(const CommunicatorPtr& communicator, const string& envName, const string&dbN
}
cout << "ok" << endl;
+ cout << "testing index creation... " << flush;
+
+ {
+ IntIdentityMap iim(connection, "intIdentity");
+
+ Ice::Identity odd;
+ odd.name = "foo";
+ odd.category = "odd";
+
+ Ice::Identity even;
+ even.name = "bar";
+ even.category = "even";
+
+ TransactionHolder txHolder(connection);
+ for(int i = 0; i < 1000; i++)
+ {
+ if(i % 2 == 0)
+ {
+ iim.put(IntIdentityMap::value_type(i, even));
+ }
+ else
+ {
+ iim.put(IntIdentityMap::value_type(i, odd));
+ }
+ }
+ txHolder.commit();
+ }
+
+ {
+ IntIdentityMapWithIndex iim(connection, "intIdentity");
+ test(iim.categoryCount("even") == 500);
+ test(iim.categoryCount("odd") == 500);
+
+ {
+ int count = 0;
+ IntIdentityMapWithIndex::iterator p = iim.findByCategory("even");
+ while(p != iim.end())
+ {
+ test(p->first % 2 == 0);
+ ++p;
+ ++count;
+ }
+ test(count == 500);
+ }
+
+ {
+ int count = 0;
+ IntIdentityMapWithIndex::iterator p = iim.findByCategory("odd");
+ while(p != iim.end())
+ {
+ test(p->first % 2 == 1);
+ ++p;
+ ++count;
+ }
+ test(count == 500);
+ }
+ iim.clear();
+ }
+
+ cout << "ok" << endl;
+
return EXIT_SUCCESS;
}