diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2011-03-16 12:55:12 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2011-03-16 12:55:12 +0900 |
| commit | 15730aa560f9fb39afd528c86fa9b50f8cbadf1c (patch) | |
| tree | b46172cbbd9103bfd4cdc6f46b014638d54c71fb /test | |
| parent | dfdf98d2f7d969f0295d940e7101befd2dbaf7a3 (diff) | |
Fixed the bug that JSONP callback function name is not encoded
properly.
Diffstat (limited to 'test')
| -rw-r--r-- | test/RpcResponseTest.cc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/RpcResponseTest.cc b/test/RpcResponseTest.cc index edd58140..68b9e90e 100644 --- a/test/RpcResponseTest.cc +++ b/test/RpcResponseTest.cc @@ -36,6 +36,12 @@ void RpcResponseTest::testToJson() "\"jsonrpc\":\"2.0\"," "\"result\":[1]}"), s); + // with callback + s = res.toJson("cb", false); + CPPUNIT_ASSERT_EQUAL(std::string("cb({\"id\":\"9\"," + "\"jsonrpc\":\"2.0\"," + "\"result\":[1]})"), + s); } { // error response @@ -51,6 +57,14 @@ void RpcResponseTest::testToJson() "\"jsonrpc\":\"2.0\"" "}"), s); + // with callback + s = res.toJson("cb", false); + CPPUNIT_ASSERT_EQUAL(std::string("cb({\"error\":{\"code\":1," + "\"message\":\"HELLO ERROR\"}," + "\"id\":null," + "\"jsonrpc\":\"2.0\"" + "})"), + s); } { // batch response @@ -66,6 +80,19 @@ void RpcResponseTest::testToJson() "}" "]"), s); + // with callback + s = toJsonBatch(results, "cb", false); + CPPUNIT_ASSERT_EQUAL(std::string("cb([" + "{\"id\":\"9\"," + "\"jsonrpc\":\"2.0\"," + "\"result\":[1]}," + "{\"error\":{\"code\":1," + "\"message\":\"HELLO ERROR\"}," + "\"id\":null," + "\"jsonrpc\":\"2.0\"" + "}" + "])"), + s); } } |
