Test casting a JsonValue to a float

This commit is contained in:
Benoit Blanchon
2014-08-01 14:58:16 +02:00
parent c10bcee324
commit 6384bc414a
2 changed files with 10 additions and 0 deletions

View File

@ -74,6 +74,11 @@ namespace ArduinoJson
return content.asDouble; return content.asDouble;
} }
operator float()
{
return (float)content.asDouble;
}
operator int() operator int()
{ {
return content.asLong; return content.asLong;

View File

@ -30,6 +30,11 @@ namespace JsonGeneratorTests
setValueAndCheckCast(3.14156); setValueAndCheckCast(3.14156);
} }
TEST_METHOD(Float)
{
setValueAndCheckCast(3.14f);
}
TEST_METHOD(Integer) TEST_METHOD(Integer)
{ {
setValueAndCheckCast(42); setValueAndCheckCast(42);