Skip to content
This repository has been archived by the owner on Apr 25, 2019. It is now read-only.

Commit

Permalink
Write more unit tests to maximize coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
bassosimone committed Feb 16, 2019
1 parent 8126f0c commit d37604e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions unit-tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,22 @@ TEST_CASE("the JSON is not copy assignable") {

TEST_CASE("the JSON is move constructible") {
REQUIRE(std::is_move_constructible<JSON>());
Result<JSON> 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<JSON>());
Result<JSON> json = JSON::parse("[1, 2, 3]");
REQUIRE(json.good);
Result<JSON> 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") {
Expand Down Expand Up @@ -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<std::string> res = json.dump();
REQUIRE(res.good);
REQUIRE(res.value.size() > 0);
std::clog << res.value << std::endl;
}

0 comments on commit d37604e

Please sign in to comment.