From 23b5237f74f8c70b940611ebcad4095c05eb9834 Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Fri, 1 Aug 2014 14:53:05 +0200 Subject: [PATCH] Test casting a JsonValue to a long --- JsonGenerator/JsonValue.h | 5 +++++ JsonGeneratorTests/JsonValue_Cast_Tests.cpp | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/JsonGenerator/JsonValue.h b/JsonGenerator/JsonValue.h index d93dc004..ea7fa898 100644 --- a/JsonGenerator/JsonValue.h +++ b/JsonGenerator/JsonValue.h @@ -69,6 +69,11 @@ namespace ArduinoJson return content.asLong; } + operator long() + { + return content.asLong; + } + size_t printTo(Print& p) const { // handmade polymorphism diff --git a/JsonGeneratorTests/JsonValue_Cast_Tests.cpp b/JsonGeneratorTests/JsonValue_Cast_Tests.cpp index 26108a75..72b5dcf1 100644 --- a/JsonGeneratorTests/JsonValue_Cast_Tests.cpp +++ b/JsonGeneratorTests/JsonValue_Cast_Tests.cpp @@ -29,6 +29,10 @@ namespace JsonGeneratorTests setValueAndCheckCast(42); } + TEST_METHOD(Long) + { + setValueAndCheckCast(42L); + } private: