forked from bblanchon/ArduinoJson
Organized test files in subfolders
This commit is contained in:
1 parent
e664c1ab05
commit
ac89d91db5
65 files changed
+4
-141
No files matched your search
+4
-1
@@ -7,7 +7,10 @@
|
|||||||
|
|
||||||
include(gtest.cmake)
|
include(gtest.cmake)
|
||||||
|
|
||||||
file(GLOB TESTS_FILES *.hpp *.cpp)
|
file(GLOB_RECURSE TESTS_FILES
|
||||||
|
*.hpp
|
||||||
|
*.cpp
|
||||||
|
)
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
|
if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
|
||||||
add_compile_options(
|
add_compile_options(
|
||||||
|
|||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,68 +0,0 @@
|
|||||||
// Copyright Benoit Blanchon 2014-2017
|
|
||||||
// MIT License
|
|
||||||
//
|
|
||||||
// Arduino JSON library
|
|
||||||
// https://bblanchon.github.io/ArduinoJson/
|
|
||||||
// If you like this project, please add a star!
|
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
|
||||||
#include <gtest/gtest.h>
|
|
||||||
|
|
||||||
struct Person {
|
|
||||||
int id;
|
|
||||||
char name[32];
|
|
||||||
};
|
|
||||||
|
|
||||||
class Issue10 : public testing::Test {
|
|
||||||
protected:
|
|
||||||
virtual void SetUp() {
|
|
||||||
Person boss;
|
|
||||||
boss.id = 1;
|
|
||||||
strcpy(boss.name, "Jeff");
|
|
||||||
Person employee;
|
|
||||||
employee.id = 2;
|
|
||||||
strcpy(employee.name, "John");
|
|
||||||
persons[0] = boss;
|
|
||||||
persons[1] = employee;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void checkJsonString(const T &p) {
|
|
||||||
char buffer[256];
|
|
||||||
p.printTo(buffer, sizeof(buffer));
|
|
||||||
|
|
||||||
EXPECT_STREQ("[{\"id\":1,\"name\":\"Jeff\"},{\"id\":2,\"name\":\"John\"}]",
|
|
||||||
buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
StaticJsonBuffer<JSON_ARRAY_SIZE(2) + 2 * JSON_OBJECT_SIZE(2)> json;
|
|
||||||
Person persons[2];
|
|
||||||
};
|
|
||||||
|
|
||||||
TEST_F(Issue10, PopulateArrayByAddingAnObject) {
|
|
||||||
JsonArray &array = json.createArray();
|
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++) {
|
|
||||||
JsonObject &object = json.createObject();
|
|
||||||
|
|
||||||
object["id"] = persons[i].id;
|
|
||||||
object["name"] = persons[i].name;
|
|
||||||
|
|
||||||
array.add(object);
|
|
||||||
}
|
|
||||||
|
|
||||||
checkJsonString(array);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(Issue10, PopulateArrayByCreatingNestedObjects) {
|
|
||||||
JsonArray &array = json.createArray();
|
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++) {
|
|
||||||
JsonObject &object = array.createNestedObject();
|
|
||||||
|
|
||||||
object["id"] = persons[i].id;
|
|
||||||
object["name"] = persons[i].name;
|
|
||||||
}
|
|
||||||
|
|
||||||
checkJsonString(array);
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
// Copyright Benoit Blanchon 2014-2017
|
|
||||||
// MIT License
|
|
||||||
//
|
|
||||||
// Arduino JSON library
|
|
||||||
// https://bblanchon.github.io/ArduinoJson/
|
|
||||||
// If you like this project, please add a star!
|
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
|
||||||
#include <gtest/gtest.h>
|
|
||||||
|
|
||||||
TEST(Issue214, IsBool) {
|
|
||||||
char json[] = "{\"ota\": {\"enabled\": true}}";
|
|
||||||
StaticJsonBuffer<JSON_OBJECT_SIZE(1) + JSON_OBJECT_SIZE(1)> jsonBuffer;
|
|
||||||
JsonObject& parsedJson = jsonBuffer.parseObject(json);
|
|
||||||
ASSERT_TRUE(parsedJson["ota"]["enabled"].is<bool>());
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
// Copyright Benoit Blanchon 2014-2017
|
|
||||||
// MIT License
|
|
||||||
//
|
|
||||||
// Arduino JSON library
|
|
||||||
// https://bblanchon.github.io/ArduinoJson/
|
|
||||||
// If you like this project, please add a star!
|
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
|
||||||
#include <gtest/gtest.h>
|
|
||||||
|
|
||||||
class Issue34 : public testing::Test {
|
|
||||||
protected:
|
|
||||||
template <typename T>
|
|
||||||
void test_with_value(T expected) {
|
|
||||||
StaticJsonBuffer<JSON_OBJECT_SIZE(1)> jsonBuffer;
|
|
||||||
|
|
||||||
JsonObject& jsonObject = jsonBuffer.createObject();
|
|
||||||
|
|
||||||
jsonObject["key"] = expected;
|
|
||||||
T actual = jsonObject["key"];
|
|
||||||
|
|
||||||
ASSERT_EQ(expected, actual);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
TEST_F(Issue34, int8_t) {
|
|
||||||
test_with_value<int8_t>(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(Issue34, uint8_t) {
|
|
||||||
test_with_value<uint8_t>(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(Issue34, int16_t) {
|
|
||||||
test_with_value<int16_t>(3);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(Issue34, uint16_t) {
|
|
||||||
test_with_value<uint16_t>(4);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(Issue34, int32_t) {
|
|
||||||
test_with_value<int32_t>(5);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(Issue34, uint32_t) {
|
|
||||||
test_with_value<uint32_t>(6);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(Issue34, float) {
|
|
||||||
test_with_value<float>(7);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(Issue34, double) {
|
|
||||||
test_with_value<double>(8);
|
|
||||||
}
|
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Reference in new issue
Block a user