-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
42 lines (37 loc) · 1.09 KB
/
main.cpp
File metadata and controls
42 lines (37 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include <array>
#include <string>
#include <sstream>
#include <doctest/doctest.h>
#include <nlohmann/json.hpp>
TEST_SUITE ("Example derived tests.") {
TEST_CASE ("No error in parsing the JSON fixture with round trip.") {
/* Example snippet:
*
* auto j = R"(
* {
* "happy": true,
* "pi": 3.14156
* }
* )"_json;
* std::string s = j.dump();
* std::cout << "compact: " << s << "\n";
* std::cout << "indented:\n"
* << j.dump(4) << "\n";
*/
auto j = R"(
{
"happy": true,
"pi": 3.14156
}
)"_json;
SUBCASE("The JSON representation is not empty in round trip.") {
std::string s = j.dump();
REQUIRE(!s.empty());
}
SUBCASE("The indentation on dump works in round trip.") {
std::string si = j.dump(42);
REQUIRE(si.find(" ") != std::string::npos);
}
}
}