aboutsummaryrefslogtreecommitdiff
path: root/test/suites/api/test_dump.c
diff options
context:
space:
mode:
authorJuan Basso <jrbasso@gmail.com>2012-06-28 22:04:36 -0400
committerJuan Basso <jrbasso@gmail.com>2012-06-28 22:04:36 -0400
commitb217cd668932a17fac002976e353541932d97128 (patch)
tree6dbeeb94abbfe887b59624462cac0164cfafbaaf /test/suites/api/test_dump.c
parenta0c262d08b46652ef2a256050ad66f65a8f95a93 (diff)
downloadjansson-b217cd668932a17fac002976e353541932d97128.zip
jansson-b217cd668932a17fac002976e353541932d97128.tar.gz
jansson-b217cd668932a17fac002976e353541932d97128.tar.bz2
Created flag to dump escaping slash
Diffstat (limited to 'test/suites/api/test_dump.c')
-rw-r--r--test/suites/api/test_dump.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/suites/api/test_dump.c b/test/suites/api/test_dump.c
index c1a3763..8cd659c 100644
--- a/test/suites/api/test_dump.c
+++ b/test/suites/api/test_dump.c
@@ -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();
}