Merge branch '1.2'
This commit is contained in:
commit
72e3948438
@ -16,4 +16,4 @@ uninstall-local:
|
||||
|
||||
clean-local:
|
||||
rm -rf _build
|
||||
rm -f ext/refcounting.pyc changes.rst
|
||||
rm -f ext/refcounting.pyc
|
||||
|
@ -29,7 +29,7 @@ for test_path in $suite_srcdir/*; do
|
||||
rm -rf $test_log
|
||||
mkdir -p $test_log
|
||||
if [ $VERBOSE -eq 1 ]; then
|
||||
echo -n "$name... "
|
||||
echo -n "$test_name... "
|
||||
fi
|
||||
|
||||
if run_test; then
|
||||
|
@ -17,7 +17,8 @@ run_test() {
|
||||
else
|
||||
$test_runner $suite_builddir/${test_name%.c} \
|
||||
>$test_log/stdout \
|
||||
2>$test_log/stderr
|
||||
2>$test_log/stderr \
|
||||
|| return 1
|
||||
valgrind_check $test_log/stderr || return 1
|
||||
fi
|
||||
}
|
||||
|
@ -205,10 +205,68 @@ static void test_set_nocheck()
|
||||
json_decref(object);
|
||||
}
|
||||
|
||||
static void test_iterators()
|
||||
{
|
||||
json_t *object, *foo, *bar, *baz;
|
||||
void *iter;
|
||||
|
||||
if(json_object_iter(NULL))
|
||||
fail("able to iterate over NULL");
|
||||
|
||||
if(json_object_iter_next(NULL, NULL))
|
||||
fail("able to increment an iterator on a NULL object");
|
||||
|
||||
object = json_object();
|
||||
foo = json_string("foo");
|
||||
bar = json_string("bar");
|
||||
baz = json_string("baz");
|
||||
if(!object || !foo || !bar || !bar)
|
||||
fail("unable to create values");
|
||||
|
||||
if(json_object_iter_next(object, NULL))
|
||||
fail("able to increment a NULL iterator");
|
||||
|
||||
if(json_object_set(object, "a", foo) ||
|
||||
json_object_set(object, "b", bar) ||
|
||||
json_object_set(object, "c", baz))
|
||||
fail("unable to populate object");
|
||||
|
||||
iter = json_object_iter(object);
|
||||
if(!iter)
|
||||
fail("unable to get iterator");
|
||||
if(strcmp(json_object_iter_key(iter), "a"))
|
||||
fail("iterating failed: wrong key");
|
||||
if(json_object_iter_value(iter) != foo)
|
||||
fail("iterating failed: wrong value");
|
||||
|
||||
iter = json_object_iter_next(object, iter);
|
||||
if(!iter)
|
||||
fail("unable to increment iterator");
|
||||
if(strcmp(json_object_iter_key(iter), "b"))
|
||||
fail("iterating failed: wrong key");
|
||||
if(json_object_iter_value(iter) != bar)
|
||||
fail("iterating failed: wrong value");
|
||||
|
||||
iter = json_object_iter_next(object, iter);
|
||||
if(!iter)
|
||||
fail("unable to increment iterator");
|
||||
if(strcmp(json_object_iter_key(iter), "c"))
|
||||
fail("iterating failed: wrong key");
|
||||
if(json_object_iter_value(iter) != baz)
|
||||
fail("iterating failed: wrong value");
|
||||
|
||||
if(json_object_iter_next(object, iter) != NULL)
|
||||
fail("able to iterate over the end");
|
||||
|
||||
json_decref(object);
|
||||
json_decref(foo);
|
||||
json_decref(bar);
|
||||
json_decref(baz);
|
||||
}
|
||||
|
||||
static void test_misc()
|
||||
{
|
||||
json_t *object, *string, *other_string, *value;
|
||||
void *iter;
|
||||
|
||||
object = json_object();
|
||||
string = json_string("test");
|
||||
@ -231,17 +289,6 @@ static void test_misc()
|
||||
if(!json_object_set(object, "a", NULL))
|
||||
fail("able to set NULL value");
|
||||
|
||||
iter = json_object_iter(object);
|
||||
if(!iter)
|
||||
fail("unable to get iterator");
|
||||
|
||||
if(strcmp(json_object_iter_key(iter), "a"))
|
||||
fail("iterating failed: wrong key");
|
||||
if(json_object_iter_value(iter) != string)
|
||||
fail("iterating failed: wrong value");
|
||||
if(json_object_iter_next(object, iter) != NULL)
|
||||
fail("able to iterate over the end");
|
||||
|
||||
/* invalid UTF-8 in key */
|
||||
if(!json_object_set(object, "a\xefz", string))
|
||||
fail("able to set invalid unicode key");
|
||||
@ -332,6 +379,7 @@ int main()
|
||||
test_update();
|
||||
test_circular();
|
||||
test_set_nocheck();
|
||||
test_iterators();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user