Merge branch 'fix-slash' of git://github.com/jrbasso/jansson

Fixes #81.
This commit is contained in:
Petri Lehtinen
2012-06-29 13:17:55 +03:00
3 changed files with 40 additions and 6 deletions

View File

@@ -133,9 +133,34 @@ static void encode_other_than_array_or_object()
}
static void escape_slashes()
{
/* Test dump escaping slashes */
json_t *json;
char *result;
json = json_object();
json_object_set_new(json, "url", json_string("https://github.com/akheron/jansson"));
result = json_dumps(json, 0);
if(!result || strcmp(result, "{\"url\": \"https://github.com/akheron/jansson\"}"))
fail("json_dumps failed to not escape slashes");
free(result);
result = json_dumps(json, JSON_ESCAPE_SLASH);
if(!result || strcmp(result, "{\"url\": \"https:\\/\\/github.com\\/akheron\\/jansson\"}"))
fail("json_dumps failed to escape slashes");
free(result);
json_decref(json);
}
static void run_tests()
{
encode_twice();
circular_references();
encode_other_than_array_or_object();
escape_slashes();
}