X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=test%2Fsuites%2Fapi%2Ftest_simple.c;h=1769c653dfe74c40a7c474e2cbae37eac5d33cb1;hb=f284e3c069abcdfc1145e939b0c284910c274d17;hp=02848794ab5f06fb9adde305c9a3028ef46c24b3;hpb=f9febb64c5dc15e03ecf3ca552e0654ee919b52e;p=jansson.git diff --git a/test/suites/api/test_simple.c b/test/suites/api/test_simple.c index 0284879..1769c65 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. @@ -150,5 +150,36 @@ int main() fail("json_null failed"); json_decref(value); + /* Test reference counting on singletons (true, false, null) */ + value = json_true(); + if(value->refcount != (unsigned int)-1) + fail("refcounting true works incorrectly"); + json_decref(value); + if(value->refcount != (unsigned int)-1) + fail("refcounting true works incorrectly"); + json_incref(value); + if(value->refcount != (unsigned int)-1) + fail("refcounting true works incorrectly"); + + value = json_false(); + if(value->refcount != (unsigned int)-1) + fail("refcounting false works incorrectly"); + json_decref(value); + if(value->refcount != (unsigned int)-1) + fail("refcounting false works incorrectly"); + json_incref(value); + if(value->refcount != (unsigned int)-1) + fail("refcounting false works incorrectly"); + + value = json_null(); + if(value->refcount != (unsigned int)-1) + fail("refcounting null works incorrectly"); + json_decref(value); + if(value->refcount != (unsigned int)-1) + fail("refcounting null works incorrectly"); + json_incref(value); + if(value->refcount != (unsigned int)-1) + fail("refcounting null works incorrectly"); + return 0; }