From 8067c3ca5b840f734571660ac9e377331f19f90a Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Sun, 25 Aug 2019 22:02:49 +0200 Subject: [PATCH] Add serialization unit tests for extreme integer values --- test/src/unit-serialization.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/src/unit-serialization.cpp b/test/src/unit-serialization.cpp index 3a0b28e4..dadec343 100644 --- a/test/src/unit-serialization.cpp +++ b/test/src/unit-serialization.cpp @@ -189,3 +189,20 @@ TEST_CASE("serialization") test("[3,\"false\",false]", "[3,\\\"false\\\",false]"); } } + +TEST_CASE_TEMPLATE("serialization for extreme integer values", T, int32_t, uint32_t, int64_t, uint64_t) +{ + SECTION("minimum") + { + constexpr auto minimum = (std::numeric_limits::min)(); + json j = minimum; + CHECK(j.dump() == std::to_string(minimum)); + } + + SECTION("maximum") + { + constexpr auto maximum = (std::numeric_limits::max)(); + json j = maximum; + CHECK(j.dump() == std::to_string(maximum)); + } +}