diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2012-02-27 03:26:51 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2012-02-27 03:26:51 +0000 |
commit | a07d4945c1a301aeaf4b67411065b9adcfac1065 (patch) | |
tree | c605de13425e7ecdcd8ee4c941a8ce97a881731a /sca-cpp/trunk/modules/json/json-test.cpp | |
parent | edc083d8056557814691d49d45b56f8244558bae (diff) |
Fix mapping between repeating XML elements, S-expression lists, and JSON array cells.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1294006 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r-- | sca-cpp/trunk/modules/json/json-test.cpp | 18 |
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; } |