2017-11-07 20:42:50 +01:00
|
|
|
// ArduinoJson - arduinojson.org
|
2018-01-05 09:20:01 +01:00
|
|
|
// Copyright Benoit Blanchon 2014-2018
|
2017-01-03 22:03:50 +01:00
|
|
|
// MIT License
|
|
|
|
|
|
|
|
#include <ArduinoJson.h>
|
2017-04-18 18:22:24 +02:00
|
|
|
#include <catch.hpp>
|
2017-01-03 22:03:50 +01:00
|
|
|
|
2018-01-19 08:32:15 +01:00
|
|
|
using namespace ArduinoJson::Internals;
|
2017-01-03 22:03:50 +01:00
|
|
|
|
2018-05-17 13:46:23 +02:00
|
|
|
TEST_CASE("Polyfills/type_traits") {
|
|
|
|
SECTION("is_base_of") {
|
2017-04-18 18:22:24 +02:00
|
|
|
REQUIRE_FALSE(
|
2018-05-17 13:46:23 +02:00
|
|
|
static_cast<bool>(is_base_of<std::istream, std::ostringstream>::value));
|
2017-04-18 18:22:24 +02:00
|
|
|
REQUIRE(
|
2018-05-17 13:46:23 +02:00
|
|
|
static_cast<bool>(is_base_of<std::istream, std::istringstream>::value));
|
2017-04-18 18:22:24 +02:00
|
|
|
REQUIRE(static_cast<bool>(
|
2018-05-17 13:46:23 +02:00
|
|
|
is_base_of<JsonVariantBase<JsonObjectSubscript<const char*> >,
|
|
|
|
JsonObjectSubscript<const char*> >::value));
|
2017-04-18 18:22:24 +02:00
|
|
|
}
|
2017-01-15 15:11:26 +01:00
|
|
|
|
2018-05-17 13:46:23 +02:00
|
|
|
SECTION("is_array") {
|
|
|
|
REQUIRE_FALSE((is_array<const char*>::value));
|
|
|
|
REQUIRE((is_array<const char[]>::value));
|
|
|
|
REQUIRE((is_array<const char[10]>::value));
|
2017-04-18 18:22:24 +02:00
|
|
|
}
|
2017-02-11 15:06:17 +01:00
|
|
|
|
2017-04-18 18:22:24 +02:00
|
|
|
SECTION("IsVariant") {
|
|
|
|
REQUIRE(
|
|
|
|
static_cast<bool>(IsVariant<JsonObjectSubscript<const char*> >::value));
|
|
|
|
REQUIRE(static_cast<bool>(IsVariant<JsonVariant>::value));
|
|
|
|
}
|
2017-02-11 15:06:17 +01:00
|
|
|
|
2018-05-17 13:46:23 +02:00
|
|
|
SECTION("is_const") {
|
|
|
|
CHECK(is_const<char>::value == false);
|
|
|
|
CHECK(is_const<const char>::value == true);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("is_signed") {
|
|
|
|
CHECK(is_signed<char>::value == true);
|
|
|
|
CHECK(is_signed<signed char>::value == true);
|
|
|
|
CHECK(is_signed<signed int>::value == true);
|
|
|
|
CHECK(is_signed<signed short>::value == true);
|
|
|
|
CHECK(is_signed<signed long>::value == true);
|
|
|
|
CHECK(is_signed<float>::value == true);
|
|
|
|
CHECK(is_signed<double>::value == true);
|
|
|
|
CHECK(is_signed<bool>::value == false);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("is_unsigned") {
|
|
|
|
CHECK(is_unsigned<unsigned char>::value == true);
|
|
|
|
CHECK(is_unsigned<unsigned int>::value == true);
|
|
|
|
CHECK(is_unsigned<unsigned short>::value == true);
|
|
|
|
CHECK(is_unsigned<unsigned long>::value == true);
|
|
|
|
CHECK(is_unsigned<bool>::value == true);
|
|
|
|
CHECK(is_unsigned<char>::value == false);
|
|
|
|
CHECK(is_unsigned<float>::value == false);
|
|
|
|
CHECK(is_unsigned<double>::value == false);
|
2018-01-14 13:46:28 +01:00
|
|
|
}
|
2017-02-11 15:06:17 +01:00
|
|
|
}
|