Files
ArduinoJson/JsonGeneratorTests/JsonValue_Cast_Tests.cpp

43 lines
857 B
C++
Raw Normal View History

2014-08-01 14:47:48 +02:00
/*
* Arduino JSON library
* Benoit Blanchon 2014 - MIT License
*/
#include "CppUnitTest.h"
#include "StringBuilder.h"
#include "JsonValue.h"
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
using namespace ArduinoJson::Generator;
using namespace ArduinoJson::Internals;
namespace JsonGeneratorTests
{
TEST_CLASS(JsonValue_Cast_Tests)
{
JsonValue value;
public:
TEST_METHOD(String)
{
2014-08-01 14:52:15 +02:00
setValueAndCheckCast("hello");
2014-08-01 14:47:48 +02:00
}
2014-08-01 14:52:15 +02:00
TEST_METHOD(Integer)
{
setValueAndCheckCast(42);
}
2014-08-01 14:47:48 +02:00
private:
2014-08-01 14:52:15 +02:00
template<typename T>
void setValueAndCheckCast(T expected)
2014-08-01 14:47:48 +02:00
{
2014-08-01 14:52:15 +02:00
value = expected;
T actual = value;
2014-08-01 14:47:48 +02:00
Assert::AreEqual(expected, actual);
}
};
}