Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for binary values #2099

Merged
merged 18 commits into from
May 13, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
✅ add tests for binary type
nlohmann committed May 9, 2020

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit 3fa94f07551fa7ab2a10c071e22c6d02ba4c2afd
8 changes: 8 additions & 0 deletions test/src/unit-constructor1.cpp
Original file line number Diff line number Diff line change
@@ -115,6 +115,14 @@ TEST_CASE("constructors")
CHECK(j.type() == t);
CHECK(j == 0.0);
}

SECTION("binary")
{
auto t = json::value_t::binary;
json j(t);
CHECK(j.type() == t);
CHECK(j == json::binary_array({}));
}
}

SECTION("create a null object (implicitly)")
15 changes: 15 additions & 0 deletions test/src/unit-constructor2.cpp
Original file line number Diff line number Diff line change
@@ -91,6 +91,13 @@ TEST_CASE("other constructors and destructor")
json k(j);
CHECK(j == k);
}

SECTION("binary")
{
json j = json::binary_array({1, 2, 3});
json k(j);
CHECK(j == k);
}
}

SECTION("move constructor")
@@ -167,6 +174,14 @@ TEST_CASE("other constructors and destructor")
k = j;
CHECK(j == k);
}

SECTION("binary")
{
json j = json::binary_array({1, 2, 3});
json k;
k = j;
CHECK(j == k);
}
}

SECTION("destructor")
16 changes: 16 additions & 0 deletions test/src/unit-element_access1.cpp
Original file line number Diff line number Diff line change
@@ -694,6 +694,22 @@ TEST_CASE("element access 1")
CHECK(it == j.end());
}
}

SECTION("binary")
{
{
json j = json::binary_array({1, 2, 3});
json::iterator it = j.erase(j.begin());
CHECK(j.type() == json::value_t::null);
CHECK(it == j.end());
}
{
json j = json::binary_array({1, 2, 3});
json::const_iterator it = j.erase(j.cbegin());
CHECK(j.type() == json::value_t::null);
CHECK(it == j.end());
}
}
}

SECTION("erase with one invalid iterator")