From d37604e95d8955bb6074096f0a3b661cde79415c Mon Sep 17 00:00:00 2001 From: Simone Basso Date: Sat, 16 Feb 2019 16:21:13 +0000 Subject: [PATCH] Write more unit tests to maximize coverage --- unit-tests.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/unit-tests.cpp b/unit-tests.cpp index 33a1800..9736a59 100644 --- a/unit-tests.cpp +++ b/unit-tests.cpp @@ -79,10 +79,22 @@ TEST_CASE("the JSON is not copy assignable") { TEST_CASE("the JSON is move constructible") { REQUIRE(std::is_move_constructible()); + Result json = JSON::parse("[1, 2, 3]"); + REQUIRE(json.good); + JSON other{std::move(json.value)}; + REQUIRE(json.value.is_null()); + REQUIRE(other.is_array()); } TEST_CASE("the JSON is move assignable") { REQUIRE(std::is_move_assignable()); + Result json = JSON::parse("[1, 2, 3]"); + REQUIRE(json.good); + Result other = JSON::parse("3.14"); + REQUIRE(other.good); + other.value = std::move(json.value); + REQUIRE(json.value.is_float64()); + REQUIRE(other.value.is_array()); } TEST_CASE("is_array works as expected") { @@ -315,3 +327,13 @@ TEST_CASE("we can successfully create a complex JSON") { REQUIRE(dump.good); std::clog << dump.value << std::endl; } + +TEST_CASE("set_value_string will base64 a string") { + JSON json; + std::string string{(char *)binary_input, sizeof(binary_input)}; + json.set_value_string(std::move(string)); + Result res = json.dump(); + REQUIRE(res.good); + REQUIRE(res.value.size() > 0); + std::clog << res.value << std::endl; +}