summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/modules/json/json-test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sca-cpp/trunk/modules/json/json-test.cpp')
-rw-r--r--sca-cpp/trunk/modules/json/json-test.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/sca-cpp/trunk/modules/json/json-test.cpp b/sca-cpp/trunk/modules/json/json-test.cpp
index 157e012b5a..ac68d7573d 100644
--- a/sca-cpp/trunk/modules/json/json-test.cpp
+++ b/sca-cpp/trunk/modules/json/json-test.cpp
@@ -66,6 +66,13 @@ const string jsecho("{\n"
" }\n"
"}");
+const string jsarray("{\n"
+ " \"fruit\": [\n"
+ " \"Apple\",\n"
+ " \"Orange\"\n"
+ " ]\n"
+ "}");
+
bool testJSON() {
const js::JSContext cx;
@@ -107,6 +114,17 @@ bool testJSON() {
const list<value> r = elementsToValues(content(readJSON(il, cx)));
assert(r == l);
}
+ {
+ const list<value> l = mklist<value>((list<value>() + "fruit" + string("Apple")), (list<value>() + "fruit" + string("Orange")));
+ ostringstream wos;
+ write(content(writeJSON(valuesToElements(l), cx)), wos);
+ assert(str(wos) == jsarray);
+
+ istringstream is(str(wos));
+ const list<string> il = streamList(is);
+ const list<value> r = elementsToValues(content(readJSON(il, cx)));
+ assert(r == l);
+ }
return true;
}