From 825ab0357eb2046d99e9ab1249b72956f62f7c24 Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Sat, 1 Nov 2014 09:09:58 +0100 Subject: [PATCH] Added integration test with a JSON sample from OpenWeatherMap --- test/IntegrationTests.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 test/IntegrationTests.cpp diff --git a/test/IntegrationTests.cpp b/test/IntegrationTests.cpp new file mode 100644 index 00000000..c2c6a02a --- /dev/null +++ b/test/IntegrationTests.cpp @@ -0,0 +1,37 @@ +// Copyright Benoit Blanchon 2014 +// MIT License +// +// Arduino JSON library +// https://github.com/bblanchon/ArduinoJson + +#include +#include +#include +#include + +using namespace ArduinoJson; + +TEST(IntegrationTests, OpenWeatherMap) { + StaticJsonBuffer<2048> json; + const char* input = + "{\"coord\":{\"lon\":-0.13,\"lat\":51.51},\"sys\":{\"type\":1,\"id\":" + "5093,\"message\":0.1177,\"country\":\"GB\",\"sunrise\":1414824893," + "\"sunset\":1414859596},\"weather\":[{\"id\":802,\"main\":\"Clouds\"," + "\"description\":\"scattered clouds\",\"icon\":\"03d\"}],\"base\":\"cmc " + "stations\",\"main\":{\"temp\":288.62,\"pressure\":1015,\"humidity\":87," + "\"temp_min\":287.15,\"temp_max\":290.15},\"wind\":{\"speed\":4.6," + "\"deg\":240},\"clouds\":{\"all\":40},\"dt\":1414825810,\"id\":2643743," + "\"name\":\"London\",\"cod\":200}"; + + char inputBuffer[1024]; + + strcpy(inputBuffer, input); + + JsonObject& o1 = json.parseObject(inputBuffer); + + char outputBuffer[1024]; + + o1.printTo(outputBuffer, sizeof(outputBuffer)); + + ASSERT_STREQ(input, outputBuffer); +} \ No newline at end of file