summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/Freeze/MapI.cpp9
-rw-r--r--cpp/test/Freeze/dbmap/Client.cpp27
-rw-r--r--cpp/test/Freeze/dbmap/Makefile2
-rw-r--r--cpp/test/Freeze/dbmap/Makefile.mak2
4 files changed, 30 insertions, 10 deletions
diff --git a/cpp/src/Freeze/MapI.cpp b/cpp/src/Freeze/MapI.cpp
index 1011606f336..a070bbd3c31 100644
--- a/cpp/src/Freeze/MapI.cpp
+++ b/cpp/src/Freeze/MapI.cpp
@@ -241,14 +241,7 @@ Freeze::IteratorHelperI::find(const Key& key) const
{
try
{
- if(_dbc->get(&dbKey, &dbValue, DB_SET) == 0)
- {
- return true;
- }
- else
- {
- return false;
- }
+ return _dbc->get(&dbKey, &dbValue, DB_SET) == 0;
}
catch(const ::DbDeadlockException& dx)
{
diff --git a/cpp/test/Freeze/dbmap/Client.cpp b/cpp/test/Freeze/dbmap/Client.cpp
index d8b69750bda..aeefc3a2133 100644
--- a/cpp/test/Freeze/dbmap/Client.cpp
+++ b/cpp/test/Freeze/dbmap/Client.cpp
@@ -508,6 +508,9 @@ run(const CommunicatorPtr& communicator, const string& envName)
m.clear();
populateDB(connection, m);
+ //
+ // Exact match
+ //
size_t length = alphabet.size();
for(size_t k = 0; k < length; ++k)
{
@@ -555,6 +558,30 @@ run(const CommunicatorPtr& communicator, const string& envName)
test(++p == m.end());
test(m.valueCount(17) == 1);
+ m.put(ByteIntMap::value_type(alphabet[21], static_cast<Int>(17)));
+
+ //
+ // Non-exact match
+ //
+ p = m.findByValue(21);
+ test(p == m.end());
+
+ test(m.valueCount(21) == 0);
+
+ p = m.findByValue(21, false);
+ test(p == m.end());
+
+ p = m.findByValue(22, false);
+ int previous = 21;
+ int count = 0;
+ while(p != m.end())
+ {
+ test(p->second > previous);
+ previous = p->second;
+ ++p;
+ count++;
+ }
+ test(count == 4);
cout << "ok " << endl;
cout << "testing concurrent access... " << flush;
diff --git a/cpp/test/Freeze/dbmap/Makefile b/cpp/test/Freeze/dbmap/Makefile
index c45ee479011..50de3cea229 100644
--- a/cpp/test/Freeze/dbmap/Makefile
+++ b/cpp/test/Freeze/dbmap/Makefile
@@ -32,7 +32,7 @@ $(CLIENT): $(OBJS)
ByteIntMap.h ByteIntMap.cpp: $(SLICE2FREEZE)
rm -f ByteIntMap.h ByteIntMap.cpp
- $(SLICE2FREEZE) --dict Test::ByteIntMap,byte,int --dict-index Test::ByteIntMap ByteIntMap
+ $(SLICE2FREEZE) --dict Test::ByteIntMap,byte,int --dict-index "Test::ByteIntMap,sort" ByteIntMap
IntIdentityMap.h IntIdentityMap.cpp: $(SLICE2FREEZE)
rm -f IntIdentityMap.h IntIdentityMap.cpp
diff --git a/cpp/test/Freeze/dbmap/Makefile.mak b/cpp/test/Freeze/dbmap/Makefile.mak
index af591c25bb2..a0e993e6f38 100644
--- a/cpp/test/Freeze/dbmap/Makefile.mak
+++ b/cpp/test/Freeze/dbmap/Makefile.mak
@@ -37,7 +37,7 @@ $(CLIENT): $(OBJS)
ByteIntMap.h ByteIntMap.cpp: $(SLICE2FREEZE)
del /q ByteIntMap.h ByteIntMap.cpp
- $(SLICE2FREEZE) --dict Test::ByteIntMap,byte,int --dict-index Test::ByteIntMap ByteIntMap
+ $(SLICE2FREEZE) --dict Test::ByteIntMap,byte,int --dict-index Test::ByteIntMap,sort ByteIntMap
IntIdentityMap.h IntIdentityMap.cpp: $(SLICE2FREEZE)
del /q IntIdentityMap.h IntIdentityMap.cpp