2017-01-06 21:07:34 +01:00
|
|
|
// Copyright Benoit Blanchon 2014-2017
|
2017-01-03 22:03:50 +01:00
|
|
|
// MIT License
|
|
|
|
//
|
|
|
|
// Arduino JSON library
|
|
|
|
// https://github.com/bblanchon/ArduinoJson
|
|
|
|
// If you like this project, please add a star!
|
|
|
|
|
|
|
|
#include <ArduinoJson.h>
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
using namespace ArduinoJson::TypeTraits;
|
|
|
|
|
2017-02-11 15:06:17 +01:00
|
|
|
TEST(TypeTraits, IsBaseOf) {
|
2017-01-03 22:03:50 +01:00
|
|
|
ASSERT_FALSE((IsBaseOf<std::istream, std::ostringstream>::value));
|
|
|
|
ASSERT_TRUE((IsBaseOf<std::istream, std::istringstream>::value));
|
2017-02-11 15:06:17 +01:00
|
|
|
ASSERT_TRUE((IsBaseOf<JsonVariantBase<JsonObjectSubscript<const char*> >,
|
|
|
|
JsonObjectSubscript<const char*> >::value));
|
2017-01-03 22:03:50 +01:00
|
|
|
}
|
2017-01-15 15:11:26 +01:00
|
|
|
|
2017-02-11 15:06:17 +01:00
|
|
|
TEST(TypeTraits, IsArray) {
|
2017-01-15 15:11:26 +01:00
|
|
|
ASSERT_FALSE((IsArray<const char*>::value));
|
|
|
|
ASSERT_TRUE((IsArray<const char[]>::value));
|
|
|
|
ASSERT_TRUE((IsArray<const char[10]>::value));
|
|
|
|
}
|
2017-02-11 15:06:17 +01:00
|
|
|
|
|
|
|
TEST(TypeTraits, IsVariant) {
|
|
|
|
ASSERT_TRUE((IsVariant<JsonObjectSubscript<const char*> >::value));
|
|
|
|
ASSERT_TRUE((IsVariant<JsonVariant>::value));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TypeTraits, IsString) {
|
|
|
|
ASSERT_TRUE((IsString<const char*>::value));
|
|
|
|
ASSERT_TRUE((IsString<std::string>::value));
|
|
|
|
ASSERT_FALSE((IsString<double>::value));
|
|
|
|
}
|