| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- /*
- * 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)
- {
- setValueAndCheckCast("hello");
- }
- TEST_METHOD(Integer)
- {
- setValueAndCheckCast(42);
- }
- TEST_METHOD(Long)
- {
- setValueAndCheckCast(42L);
- }
- TEST_METHOD(Bool)
- {
- setValueAndCheckCast(true);
- setValueAndCheckCast(false);
- }
- private:
- template<typename T>
- void setValueAndCheckCast(T expected)
- {
- value = expected;
- T actual = value;
- Assert::AreEqual(expected, actual);
- }
- };
- }
|