From 3fa94f07551fa7ab2a10c071e22c6d02ba4c2afd Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 9 May 2020 13:46:24 +0200 Subject: [PATCH] :white_check_mark: add tests for binary type --- test/src/unit-constructor1.cpp | 8 ++++++++ test/src/unit-constructor2.cpp | 15 +++++++++++++++ test/src/unit-element_access1.cpp | 16 ++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/test/src/unit-constructor1.cpp b/test/src/unit-constructor1.cpp index 2caf26535..6f6e00147 100644 --- a/test/src/unit-constructor1.cpp +++ b/test/src/unit-constructor1.cpp @@ -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)") diff --git a/test/src/unit-constructor2.cpp b/test/src/unit-constructor2.cpp index 69429b0b3..8bbb5197c 100644 --- a/test/src/unit-constructor2.cpp +++ b/test/src/unit-constructor2.cpp @@ -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") diff --git a/test/src/unit-element_access1.cpp b/test/src/unit-element_access1.cpp index ebec93284..069beb504 100644 --- a/test/src/unit-element_access1.cpp +++ b/test/src/unit-element_access1.cpp @@ -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")