From 028ff6676ebcd9e6de7e4605f6e50cae97ed3ec3 Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Fri, 1 Aug 2014 14:54:34 +0200 Subject: [PATCH] Test casting a JsonValue to a bool --- JsonGenerator/JsonValue.h | 5 +++++ JsonGeneratorTests/JsonValue_Cast_Tests.cpp | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/JsonGenerator/JsonValue.h b/JsonGenerator/JsonValue.h index ea7fa898..12b491df 100644 --- a/JsonGenerator/JsonValue.h +++ b/JsonGenerator/JsonValue.h @@ -59,6 +59,11 @@ namespace ArduinoJson content.asDouble = value; } + operator bool() + { + return content.asBool; + } + operator const char*() { return ""; diff --git a/JsonGeneratorTests/JsonValue_Cast_Tests.cpp b/JsonGeneratorTests/JsonValue_Cast_Tests.cpp index 72b5dcf1..3bbd73a7 100644 --- a/JsonGeneratorTests/JsonValue_Cast_Tests.cpp +++ b/JsonGeneratorTests/JsonValue_Cast_Tests.cpp @@ -34,6 +34,12 @@ namespace JsonGeneratorTests setValueAndCheckCast(42L); } + TEST_METHOD(Bool) + { + setValueAndCheckCast(true); + setValueAndCheckCast(false); + } + private: template