From a35d93e9804a568c431886649aa89bcd396d3168 Mon Sep 17 00:00:00 2001 From: Niels Date: Sun, 8 Feb 2015 16:57:53 +0100 Subject: [PATCH] try with GCC 4.9 --- .travis.yml | 6 +- test/unit.cpp | 348 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 351 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index e6d4ad97f..01308341a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,8 @@ compiler: before_install: - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y - sudo apt-get update -qq - - if [ "$CXX" = "g++" ]; then sudo apt-get install -qq g++-4.8; fi - - if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi + - if [ "$CXX" = "g++" ]; then sudo apt-get install -qq g++-4.9; fi + - if [ "$CXX" = "g++" ]; then export CXX="g++-4.9" CC="gcc-4.9"; fi - sudo pip install cpp-coveralls pyyaml - sudo apt-get install valgrind @@ -24,4 +24,4 @@ after_success: - make clean - make json_unit CXXFLAGS="-fprofile-arcs -ftest-coverage" - ./json_unit - - coveralls --gcov-options '\-lp' --gcov 'gcov-4.8' + - coveralls --exclude test/catch.hpp --exclude test/unit.cpp --include src/json.hpp --gcov-options '\-lp' --gcov 'gcov-4.9' diff --git a/test/unit.cpp b/test/unit.cpp index ca894aeca..1265b54a0 100644 --- a/test/unit.cpp +++ b/test/unit.cpp @@ -1478,6 +1478,150 @@ TEST_CASE("value conversion") CHECK(json(n) == j); } + SECTION("int8_t") + { + int8_t n = j.get(); + CHECK(json(n) == j); + } + + SECTION("int16_t") + { + int16_t n = j.get(); + CHECK(json(n) == j); + } + + SECTION("int32_t") + { + int32_t n = j.get(); + CHECK(json(n) == j); + } + + SECTION("int64_t") + { + int64_t n = j.get(); + CHECK(json(n) == j); + } + + SECTION("int8_fast_t") + { + int_fast8_t n = j.get(); + CHECK(json(n) == j); + } + + SECTION("int16_fast_t") + { + int_fast16_t n = j.get(); + CHECK(json(n) == j); + } + + SECTION("int32_fast_t") + { + int_fast32_t n = j.get(); + CHECK(json(n) == j); + } + + SECTION("int64_fast_t") + { + int_fast64_t n = j.get(); + CHECK(json(n) == j); + } + + SECTION("int8_least_t") + { + int_least8_t n = j.get(); + CHECK(json(n) == j); + } + + SECTION("int16_least_t") + { + int_least16_t n = j.get(); + CHECK(json(n) == j); + } + + SECTION("int32_least_t") + { + int_least32_t n = j.get(); + CHECK(json(n) == j); + } + + SECTION("int64_least_t") + { + int_least64_t n = j.get(); + CHECK(json(n) == j); + } + + SECTION("uint8_t") + { + uint8_t n = j.get(); + CHECK(json(n) == j); + } + + SECTION("uint16_t") + { + uint16_t n = j.get(); + CHECK(json(n) == j); + } + + SECTION("uint32_t") + { + uint32_t n = j.get(); + CHECK(json(n) == j); + } + + SECTION("uint64_t") + { + uint64_t n = j.get(); + CHECK(json(n) == j); + } + + SECTION("uint8_fast_t") + { + uint_fast8_t n = j.get(); + CHECK(json(n) == j); + } + + SECTION("uint16_fast_t") + { + uint_fast16_t n = j.get(); + CHECK(json(n) == j); + } + + SECTION("uint32_fast_t") + { + uint_fast32_t n = j.get(); + CHECK(json(n) == j); + } + + SECTION("uint64_fast_t") + { + uint_fast64_t n = j.get(); + CHECK(json(n) == j); + } + + SECTION("uint8_least_t") + { + uint_least8_t n = j.get(); + CHECK(json(n) == j); + } + + SECTION("uint16_least_t") + { + uint_least16_t n = j.get(); + CHECK(json(n) == j); + } + + SECTION("uint32_least_t") + { + uint_least32_t n = j.get(); + CHECK(json(n) == j); + } + + SECTION("uint64_least_t") + { + uint_least64_t 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); @@ -1488,4 +1632,208 @@ TEST_CASE("value conversion") CHECK_NOTHROW(json(json::value_t::number_float).get()); } } + + SECTION("get an integer number (implicit)") + { + 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; + CHECK(json(n) == j); + } + + SECTION("unsigned short") + { + unsigned short n = j; + CHECK(json(n) == j); + } + + SECTION("int") + { + int n = j; + CHECK(json(n) == j); + } + + SECTION("unsigned int") + { + unsigned int n = j; + CHECK(json(n) == j); + } + + SECTION("long") + { + long n = j; + CHECK(json(n) == j); + } + + SECTION("unsigned long") + { + unsigned long n = j; + CHECK(json(n) == j); + } + + SECTION("long long") + { + long long n = j; + CHECK(json(n) == j); + } + + SECTION("unsigned long long") + { + unsigned long long n = j; + CHECK(json(n) == j); + } + + SECTION("int8_t") + { + int8_t n = j; + CHECK(json(n) == j); + } + + SECTION("int16_t") + { + int16_t n = j; + CHECK(json(n) == j); + } + + SECTION("int32_t") + { + int32_t n = j; + CHECK(json(n) == j); + } + + SECTION("int64_t") + { + int64_t n = j; + CHECK(json(n) == j); + } + + SECTION("int8_fast_t") + { + int_fast8_t n = j; + CHECK(json(n) == j); + } + + SECTION("int16_fast_t") + { + int_fast16_t n = j; + CHECK(json(n) == j); + } + + SECTION("int32_fast_t") + { + int_fast32_t n = j; + CHECK(json(n) == j); + } + + SECTION("int64_fast_t") + { + int_fast64_t n = j; + CHECK(json(n) == j); + } + + SECTION("int8_least_t") + { + int_least8_t n = j; + CHECK(json(n) == j); + } + + SECTION("int16_least_t") + { + int_least16_t n = j; + CHECK(json(n) == j); + } + + SECTION("int32_least_t") + { + int_least32_t n = j; + CHECK(json(n) == j); + } + + SECTION("int64_least_t") + { + int_least64_t n = j; + CHECK(json(n) == j); + } + + SECTION("uint8_t") + { + uint8_t n = j; + CHECK(json(n) == j); + } + + SECTION("uint16_t") + { + uint16_t n = j; + CHECK(json(n) == j); + } + + SECTION("uint32_t") + { + uint32_t n = j; + CHECK(json(n) == j); + } + + SECTION("uint64_t") + { + uint64_t n = j; + CHECK(json(n) == j); + } + + SECTION("uint8_fast_t") + { + uint_fast8_t n = j; + CHECK(json(n) == j); + } + + SECTION("uint16_fast_t") + { + uint_fast16_t n = j; + CHECK(json(n) == j); + } + + SECTION("uint32_fast_t") + { + uint_fast32_t n = j; + CHECK(json(n) == j); + } + + SECTION("uint64_fast_t") + { + uint_fast64_t n = j; + CHECK(json(n) == j); + } + + SECTION("uint8_least_t") + { + uint_least8_t n = j; + CHECK(json(n) == j); + } + + SECTION("uint16_least_t") + { + uint_least16_t n = j; + CHECK(json(n) == j); + } + + SECTION("uint32_least_t") + { + uint_least32_t n = j; + CHECK(json(n) == j); + } + + SECTION("uint64_least_t") + { + uint_least64_t n = j; + CHECK(json(n) == j); + } + } }