X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=test%2Fsuites%2Fapi%2Ftest_simple.c;h=45f22c788266a3a6412ff3b0690cc909f74b54b2;hb=08dc8d9bafcb13bb1541894918f4a394e644e6e1;hp=9d7691e494bfb600906c743a3d03b597eb17edf3;hpb=6637b976edd508cc9413ce954fe4275eab8c2c69;p=jansson.git diff --git a/test/suites/api/test_simple.c b/test/suites/api/test_simple.c index 9d7691e..45f22c7 100644 --- a/test/suites/api/test_simple.c +++ b/test/suites/api/test_simple.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009 Petri Lehtinen + * Copyright (c) 2009, 2010 Petri Lehtinen * * Jansson is free software; you can redistribute it and/or modify * it under the terms of the MIT license. See LICENSE for details. @@ -73,6 +73,33 @@ int main() if(value) fail("json_string() failed"); + value = json_string_nocheck("foo"); + if(!value) + fail("json_string_nocheck failed"); + if(strcmp(json_string_value(value), "foo")) + fail("invalid string value"); + + if(json_string_set_nocheck(value, "bar")) + fail("json_string_set_nocheck failed"); + if(strcmp(json_string_value(value), "bar")) + fail("invalid string value"); + + json_decref(value); + + /* invalid UTF-8 */ + value = json_string_nocheck("qu\xff"); + if(!value) + fail("json_string_nocheck failed"); + if(strcmp(json_string_value(value), "qu\xff")) + fail("invalid string value"); + + if(json_string_set_nocheck(value, "\xfd\xfe\xff")) + fail("json_string_set_nocheck failed"); + if(strcmp(json_string_value(value), "\xfd\xfe\xff")) + fail("invalid string value"); + + json_decref(value); + value = json_integer(123); if(!value)