-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
45 lines (39 loc) · 1.39 KB
/
main.cpp
File metadata and controls
45 lines (39 loc) · 1.39 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
43
44
45
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include <array>
#include <string>
#include <sstream>
#include <doctest/doctest.h>
#include <toml++/toml.h>
using namespace std::string_view_literals;
static constexpr std::string_view configuration = R"(
[library]
name = "toml++"
authors = ["Mark"]
cpp = 17
)"sv;
TEST_SUITE ("Example derived tests.") {
TEST_CASE ("No error in parsing the configuration fixture with round trip.") {
/* Example snippet:
*
* toml::table tbl = toml::parse(configuration);
*/
toml::table tbl = toml::parse(configuration);
std::ostringstream os;
os << tbl;
SUBCASE("The configuration repersentation is not empty in round trip.") {
REQUIRE(!os.str().empty());
}
SUBCASE("The section is present in round trip.") {
REQUIRE(os.str().find("[library]") != std::string::npos);
}
SUBCASE("The array values of the authors key are not lost in round trip.") {
REQUIRE(os.str().find("authors = [ 'Mark' ]") != std::string::npos);
}
SUBCASE("The cpp key and value are kept in round trip.") {
REQUIRE(os.str().find("cpp = 17") != std::string::npos);
}
SUBCASE("The name value keeps the quoting in round trip.") {
REQUIRE(os.str().find("name = 'toml++'") != std::string::npos);
}
}
}