Commit 82473a64 authored by Matthieu Dorier's avatar Matthieu Dorier
Browse files

updated test to test json-based functions

parent 18ed7257
......@@ -174,6 +174,16 @@ class CollectionTest : public CppUnit::TestFixture,
"result should have 0 records.",
0, (int)results.size());
// Filter into a Json result
code = "function($rec) { return $rec.papers > 35; }";
Json::Value json_result;
"it should be possible to filter from an empty collection.",
coll.filter(code, &json_result));
"result should have 2 records.",
2, (int)json_result.size());
void testUpdate() {
......@@ -206,6 +216,22 @@ class CollectionTest : public CppUnit::TestFixture,
"update should throw for a record that does not exist.",
coll.update(records_str.size(), new_content),
// Update with a Json record
Json::Value new_content_json;
new_content_json["name"] = "Bob";
new_content_json["city"] = "London";
new_content_json["papers"] = 4;
"update should not throw.",
coll.update(0, new_content_json));
// Check the new content
Json::Value val2;
coll.fetch(0, &val2);
"fetch should give the updated value.",
val2["name"].asString(), std::string("Bob"));
void testAll() {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment