mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-29 10:17:39 +02:00
Replace ConverterNeedsWriteableRef
with function_traits
This commit is contained in:
@ -140,15 +140,3 @@ TEST_CASE("Custom converter with specialization") {
|
||||
REQUIRE(doc["value"]["imag"] == 3);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("ConverterNeedsWriteableRef") {
|
||||
using namespace ArduinoJson::detail;
|
||||
CHECK(ConverterNeedsWriteableRef<int>::value == false);
|
||||
CHECK(ConverterNeedsWriteableRef<float>::value == false);
|
||||
CHECK(ConverterNeedsWriteableRef<JsonVariant>::value == true);
|
||||
CHECK(ConverterNeedsWriteableRef<JsonVariantConst>::value == false);
|
||||
CHECK(ConverterNeedsWriteableRef<JsonObject>::value == true);
|
||||
CHECK(ConverterNeedsWriteableRef<JsonObjectConst>::value == false);
|
||||
CHECK(ConverterNeedsWriteableRef<JsonArray>::value == true);
|
||||
CHECK(ConverterNeedsWriteableRef<JsonArrayConst>::value == false);
|
||||
}
|
||||
|
@ -17,3 +17,24 @@ TEST_CASE("JsonVariantConst::as<T>()") {
|
||||
REQUIRE(var.as<const char*>() == std::string("hello"));
|
||||
REQUIRE(var.as<std::string>() == std::string("hello"));
|
||||
}
|
||||
|
||||
TEST_CASE("Invalid conversions") {
|
||||
using namespace ArduinoJson::detail;
|
||||
|
||||
JsonVariantConst variant;
|
||||
|
||||
CHECK(is_same<decltype(variant.as<int>()), int>::value);
|
||||
CHECK(is_same<decltype(variant.as<float>()), float>::value);
|
||||
CHECK(is_same<decltype(variant.as<JsonVariantConst>()),
|
||||
JsonVariantConst>::value);
|
||||
CHECK(
|
||||
is_same<decltype(variant.as<JsonObjectConst>()), JsonObjectConst>::value);
|
||||
CHECK(is_same<decltype(variant.as<JsonArrayConst>()), JsonArrayConst>::value);
|
||||
|
||||
CHECK(is_same<decltype(variant.as<JsonVariant>()),
|
||||
InvalidConversion<JsonVariantConst, JsonVariant>>::value);
|
||||
CHECK(is_same<decltype(variant.as<JsonObject>()),
|
||||
InvalidConversion<JsonVariantConst, JsonObject>>::value);
|
||||
CHECK(is_same<decltype(variant.as<JsonArray>()),
|
||||
InvalidConversion<JsonVariantConst, JsonArray>>::value);
|
||||
}
|
||||
|
@ -58,5 +58,10 @@
|
||||
// issue #1914
|
||||
#define V7 7
|
||||
|
||||
// STM32, Mbed, Particle
|
||||
#define A0 16
|
||||
#define A1 17
|
||||
#define A2 18
|
||||
|
||||
// catch.hpp mutes several warnings, this file also allows to detect them
|
||||
#include "ArduinoJson.h"
|
||||
|
Reference in New Issue
Block a user