From 838facbb434920773d6898a72e9a3f8db2e08511 Mon Sep 17 00:00:00 2001 From: Qianqian Fang Date: Tue, 17 May 2022 18:31:53 -0400 Subject: [PATCH] update unit tests for negative sized containers --- tests/src/unit-bjdata.cpp | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/tests/src/unit-bjdata.cpp b/tests/src/unit-bjdata.cpp index 0a1e6e02d..8bebca416 100644 --- a/tests/src/unit-bjdata.cpp +++ b/tests/src/unit-bjdata.cpp @@ -2518,25 +2518,11 @@ TEST_CASE("BJData") std::vector v5 = {'[', '$', 'I', '#', '[', 'i', 0xF5, 'i', 0xF1, ']'}; std::vector v6 = {'[', '#', '[', 'i', 0xF3, 'i', 0x02, ']'}; - json _; - static bool is_64bit = (sizeof(size_t) == 8); - - if (is_64bit) - { - CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v1), "[json.exception.out_of_range.408] excessive array size: 18446744073709551601", json::out_of_range&); - CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v2), "[json.exception.out_of_range.408] excessive array size: 18446744073709551602", json::out_of_range&); - CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v3), "[json.exception.out_of_range.408] excessive array size: 18446744073709551592", json::out_of_range&); - CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v4), "[json.exception.out_of_range.408] excessive array size: 18446744073709551607", json::out_of_range&); - } - else - { - CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v1), "[json.exception.out_of_range.408] excessive array size: 4294967281", json::out_of_range&); - CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v2), "[json.exception.out_of_range.408] excessive array size: 4294967282", json::out_of_range&); - CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v3), "[json.exception.out_of_range.408] excessive array size: 4294967272", json::out_of_range&); - CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v4), "[json.exception.out_of_range.408] excessive array size: 4294967287", json::out_of_range&); - } - CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v5), "[json.exception.parse_error.110] parse error at byte 11: syntax error while parsing BJData number: unexpected end of input", json::parse_error&); - + CHECK(json::from_bjdata(v1, true, false).is_discarded()); + CHECK(json::from_bjdata(v2, true, false).is_discarded()); + CHECK(json::from_bjdata(v3, true, false).is_discarded()); + CHECK(json::from_bjdata(v4, true, false).is_discarded()); + CHECK(json::from_bjdata(v5, true, false).is_discarded()); CHECK(json::from_bjdata(v6, true, false).is_discarded()); }