mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
audit_logging:tests: Add big_int test for json_add_int
Show that `json_add_int` can't handle value larger than int32 due to overflow. Add knownfail. Signed-off-by: Li Yuxuan <liyuxuan.darfux@bytedance.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
b3146763a4
commit
35aa7db641
@ -63,8 +63,10 @@ static void test_json_add_int(_UNUSED_ void **state)
|
||||
{
|
||||
struct json_object object;
|
||||
struct json_t *value = NULL;
|
||||
json_int_t m;
|
||||
double n;
|
||||
int rc = 0;
|
||||
intmax_t big_int = ((intmax_t)1)<<33;
|
||||
|
||||
object = json_new_object();
|
||||
rc = json_add_int(&object, "positive_one", 1);
|
||||
@ -73,8 +75,10 @@ static void test_json_add_int(_UNUSED_ void **state)
|
||||
assert_int_equal(0, rc);
|
||||
rc = json_add_int(&object, "negative_one", -1);
|
||||
assert_int_equal(0, rc);
|
||||
rc = json_add_int(&object, "big_int", big_int);
|
||||
assert_int_equal(0, rc);
|
||||
|
||||
assert_int_equal(3, json_object_size(object.root));
|
||||
assert_int_equal(4, json_object_size(object.root));
|
||||
|
||||
value = json_object_get(object.root, "positive_one");
|
||||
assert_true(json_is_integer(value));
|
||||
@ -91,6 +95,11 @@ static void test_json_add_int(_UNUSED_ void **state)
|
||||
n = json_number_value(value);
|
||||
assert_true(n == -1.0);
|
||||
|
||||
value = json_object_get(object.root, "big_int");
|
||||
assert_true(json_is_integer(value));
|
||||
m = json_integer_value(value);
|
||||
assert_int_equal(m, big_int);
|
||||
|
||||
object.valid = false;
|
||||
rc = json_add_int(&object, "should fail 1", 0xf1);
|
||||
assert_int_equal(JSON_ERROR, rc);
|
||||
|
1
selftest/knownfail.d/json_add_int
Normal file
1
selftest/knownfail.d/json_add_int
Normal file
@ -0,0 +1 @@
|
||||
lib.audit_logging.audit_logging.test_json_add_int\(none\)
|
Loading…
Reference in New Issue
Block a user