Skip to content

Commit

Permalink
Add dump tests template
Browse files Browse the repository at this point in the history
  • Loading branch information
st235 committed Jun 28, 2024
1 parent 999725e commit ec6d575
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ add_executable(jsonc_tests
tests/json_parser_malformed_json_tests.cpp
tests/json_valid_json_tests.cpp
tests/json_beautifier_tests.cpp
tests/json_dump_tests.cpp
)

target_link_libraries(jsonc_tests jsonc)
Expand Down
29 changes: 29 additions & 0 deletions tests/json_dump_tests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <gtest/gtest.h>

#include <string>
#include <memory>
#include <utility>

#include "json.h"

class JsonDumpsTestingFixture: public ::testing::TestWithParam<std::pair<json::Json, std::string>> {};

INSTANTIATE_TEST_SUITE_P(
JsonDumpTests,
JsonDumpsTestingFixture,
::testing::Values(
// primitives
std::make_pair(json::Json::null(), "null")
)
);

TEST_P(JsonDumpsTestingFixture, JsonYieldsValidDump) {
const auto& pair = GetParam();

const auto& json = pair.first;
const auto& expected_json = pair.second;

const auto& opt_dumped_json = json::Json::toJson(json);

EXPECT_EQ(expected_json, opt_dumped_json);
}

0 comments on commit ec6d575

Please sign in to comment.