JsonObjectIteratorTests.cpp 671 B

1234567891011121314151617181920212223242526272829303132
  1. #include "CppUnitTest.h"
  2. #include "JsonParser.h"
  3. using namespace Microsoft::VisualStudio::CppUnitTestFramework;
  4. using namespace ArduinoJson::Parser;
  5. namespace JsonParserTests
  6. {
  7. TEST_CLASS(JsonArrayIteratorTests)
  8. {
  9. public:
  10. TEST_METHOD(ThreeIntegers)
  11. {
  12. char json [] = "[1,2,3]";
  13. long expected [] = { 1, 2, 3 };
  14. JsonParser<4> parser;
  15. JsonValue v = parser.parse(json);
  16. JsonArray a = (ArduinoJson::Parser::JsonArray)v;
  17. int index = 0;
  18. for (long i : a)
  19. {
  20. Assert::AreEqual(expected[index++], i);
  21. }
  22. }
  23. };
  24. }