From d6f54711f30394f28b85091fc366a1c92e0fd71a Mon Sep 17 00:00:00 2001 From: Niels Date: Sun, 8 Feb 2015 16:44:27 +0100 Subject: [PATCH] hello coveralls... --- .travis.yml | 2 +- test/unit.cpp | 79 +++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 75 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3a808aac..e6d4ad97 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,4 +24,4 @@ after_success: - make clean - make json_unit CXXFLAGS="-fprofile-arcs -ftest-coverage" - ./json_unit - - coveralls --exclude test/catch.hpp --include src/json.hpp --gcov-options '\-lp' --gcov 'gcov-4.8' + - coveralls --gcov-options '\-lp' --gcov 'gcov-4.8' diff --git a/test/unit.cpp b/test/unit.cpp index 49a5473b..ca894aec 100644 --- a/test/unit.cpp +++ b/test/unit.cpp @@ -1197,7 +1197,7 @@ TEST_CASE("value conversion") std::unordered_multimap o = j.get>(); CHECK(json(o) == j); } - + SECTION("exception in case of a non-object type") { CHECK_THROWS_AS(json(json::value_t::null).get(), std::logic_error); @@ -1331,7 +1331,7 @@ TEST_CASE("value conversion") { json::string_t s_reference {"Hello world"}; json j(s_reference); - + SECTION("string_t") { json::string_t s = j.get(); @@ -1359,7 +1359,7 @@ TEST_CASE("value conversion") { json::string_t s_reference {"Hello world"}; json j(s_reference); - + SECTION("string_t") { json::string_t s = j; @@ -1377,7 +1377,7 @@ TEST_CASE("value conversion") { json::boolean_t b_reference {true}; json j(b_reference); - + SECTION("boolean_t") { json::boolean_t b = j.get(); @@ -1405,7 +1405,7 @@ TEST_CASE("value conversion") { json::boolean_t b_reference {true}; json j(b_reference); - + SECTION("boolean_t") { json::boolean_t b = j; @@ -1419,4 +1419,73 @@ TEST_CASE("value conversion") } } + SECTION("get an integer number (explicit)") + { + json::number_integer_t n_reference {42}; + json j(n_reference); + + SECTION("number_integer_t") + { + json::number_integer_t n = j.get(); + CHECK(json(n) == j); + } + + SECTION("short") + { + short n = j.get(); + CHECK(json(n) == j); + } + + SECTION("unsigned short") + { + unsigned short n = j.get(); + CHECK(json(n) == j); + } + + SECTION("int") + { + int n = j.get(); + CHECK(json(n) == j); + } + + SECTION("unsigned int") + { + unsigned int n = j.get(); + CHECK(json(n) == j); + } + + SECTION("long") + { + long n = j.get(); + CHECK(json(n) == j); + } + + SECTION("unsigned long") + { + unsigned long n = j.get(); + CHECK(json(n) == j); + } + + SECTION("long long") + { + long long n = j.get(); + CHECK(json(n) == j); + } + + SECTION("unsigned long long") + { + unsigned long long n = j.get(); + CHECK(json(n) == j); + } + + SECTION("exception in case of a non-number type") + { + CHECK_THROWS_AS(json(json::value_t::null).get(), std::logic_error); + CHECK_THROWS_AS(json(json::value_t::object).get(), std::logic_error); + CHECK_THROWS_AS(json(json::value_t::array).get(), std::logic_error); + CHECK_THROWS_AS(json(json::value_t::string).get(), std::logic_error); + CHECK_THROWS_AS(json(json::value_t::boolean).get(), std::logic_error); + CHECK_NOTHROW(json(json::value_t::number_float).get()); + } + } }