mirror of
https://github.com/marzer/tomlplusplus.git
synced 2026-02-23 16:22:11 +00:00
new file: .editorconfig new file: .gitattributes new file: .gitignore new file: .gitmodules new file: LICENSE new file: README.md new file: examples/example.cpp new file: examples/example.toml new file: examples/meson.build new file: include/toml++/toml.h new file: include/toml++/toml_array.h new file: include/toml++/toml_common.h new file: include/toml++/toml_formatter.h new file: include/toml++/toml_node.h new file: include/toml++/toml_node_view.h new file: include/toml++/toml_parser.h new file: include/toml++/toml_table.h new file: include/toml++/toml_utf8.h new file: include/toml++/toml_utf8_generated.h new file: include/toml++/toml_value.h new file: meson.build new file: python/ci_single_header_check.py new file: python/generate_single_header.py new file: python/generate_unicode_functions.py new file: tests/catch2 new file: tests/catch2.h new file: tests/lifetimes.cpp new file: tests/main.cpp new file: tests/meson.build new file: tests/parsing_arrays.cpp new file: tests/parsing_booleans.cpp new file: tests/parsing_comments.cpp new file: tests/parsing_dates_and_times.cpp new file: tests/parsing_floats.cpp new file: tests/parsing_integers.cpp new file: tests/parsing_key_value_pairs.cpp new file: tests/parsing_spec_example.cpp new file: tests/parsing_strings.cpp new file: tests/parsing_tables.cpp new file: tests/tests.cpp new file: tests/tests.h new file: toml.hpp new file: vs/.runsettings new file: vs/example.vcxproj new file: vs/test_char.vcxproj new file: vs/test_char8.vcxproj new file: vs/test_char8_noexcept.vcxproj new file: vs/test_char_noexcept.vcxproj new file: vs/test_strict_char.vcxproj new file: vs/test_strict_char8.vcxproj new file: vs/test_strict_char8_noexcept.vcxproj new file: vs/test_strict_char_noexcept.vcxproj new file: vs/toml++.natvis new file: vs/toml++.props new file: vs/toml++.sln new file: vs/toml++.vcxproj new file: vs/toml++.vcxproj.filters
41 lines
1.3 KiB
C++
41 lines
1.3 KiB
C++
#include "tests.h"
|
|
|
|
TEST_CASE("lifetime - tables")
|
|
{
|
|
static constexpr auto filename = "foo.toml"sv;
|
|
|
|
parsing_should_succeed(
|
|
S(R"(test = { val1 = "foo" })"sv),
|
|
[&](table&& tbl) noexcept
|
|
{
|
|
CHECK(tbl.region().begin == source_position{ 1, 1 });
|
|
CHECK(tbl.region().end == source_position{ 1, 25 });
|
|
CHECK(tbl.region().path);
|
|
CHECK(*tbl.region().path == filename);
|
|
CHECK(tbl.size() == 1_sz);
|
|
REQUIRE(tbl[S("test")].as<table>());
|
|
CHECK(tbl[S("test")].as<table>()->size() == 1_sz);
|
|
CHECK(tbl[S("test")][S("val1")] == S("foo"sv));
|
|
|
|
table test_table;
|
|
CHECK(test_table.region().begin == source_position{});
|
|
CHECK(test_table.region().end == source_position{});
|
|
CHECK(!test_table.region().path);
|
|
CHECK(test_table.size() == 0_sz);
|
|
CHECK(!test_table[S("test")].as<table>());
|
|
|
|
test_table = std::move(tbl);
|
|
CHECK(test_table.region().begin == source_position{ 1, 1 });
|
|
CHECK(test_table.region().end == source_position{ 1, 25 });
|
|
CHECK(test_table.region().path);
|
|
CHECK(*test_table.region().path == filename);
|
|
CHECK(test_table.size() == 1_sz);
|
|
REQUIRE(test_table[S("test")].as<table>());
|
|
CHECK(test_table[S("test")].as<table>()->size() == 1_sz);
|
|
CHECK(test_table[S("test")][S("val1")] == S("foo"sv));
|
|
},
|
|
filename
|
|
);
|
|
|
|
}
|