Browse Source

Fixed error when assigning a `volatile int` to a `JsonVariant` (issue #415)

Benoit Blanchon 9 years ago
parent
commit
11432253a1
3 changed files with 15 additions and 1 deletions
  1. 5 0
      CHANGELOG.md
  2. 1 1
      include/ArduinoJson/TypeTraits/IsBaseOf.hpp
  3. 9 0
      test/JsonObject_Subscript_Tests.cpp

+ 5 - 0
CHANGELOG.md

@@ -1,6 +1,11 @@
 ArduinoJson: change log
 =======================
 
+HEAD
+----
+
+* Fixed error when assigning a `volatile int` to a `JsonVariant` (issue #415)
+
 v5.8.0
 ------
 

+ 1 - 1
include/ArduinoJson/TypeTraits/IsBaseOf.hpp

@@ -19,7 +19,7 @@ class IsBaseOf {
   typedef char No[2];
 
   static Yes &probe(const TBase *);
-  static No &probe(const void *);
+  static No &probe(...);
 
  public:
   enum {

+ 9 - 0
test/JsonObject_Subscript_Tests.cpp

@@ -38,6 +38,15 @@ TEST_(StoreInteger) {
   EXPECT_FALSE(_object["hello"].is<double>());
 }
 
+TEST_(StoreVolatileInteger) {  // issue #415
+  volatile int i = 123;
+  _object["hello"] = i;
+
+  EXPECT_EQ(123, _object["hello"].as<int>());
+  EXPECT_TRUE(_object["hello"].is<int>());
+  EXPECT_FALSE(_object["hello"].is<double>());
+}
+
 TEST_(StoreDouble) {
   _object["hello"] = 123.45;