| 167 | } |
| 168 | |
| 169 | void checkJSONStr(std::string json, |
| 170 | slice expectedStr, |
| 171 | int expectedErr = JSONSL_ERROR_SUCCESS) |
| 172 | { |
| 173 | json = std::string("[\"") + json + std::string("\"]"); |
| 174 | JSONConverter j(enc); |
| 175 | j.encodeJSON(slice(json)); |
| 176 | REQUIRE(j.jsonError() == expectedErr); |
| 177 | if (j.jsonError()) { |
| 178 | enc.reset(); |
| 179 | return; |
| 180 | } |
| 181 | endEncoding(); |
| 182 | REQUIRE(expectedStr); // expected success |
| 183 | auto a = checkArray(1); |
| 184 | auto output = a->get(0)->asString(); |
| 185 | REQUIRE(output == slice(expectedStr)); |
| 186 | } |
| 187 | |
| 188 | void checkJSONStr(std::string json, |
| 189 | const char *expectedStr, |