tomlplusplus/tests/parsing_comments.cpp

113 lines
3.0 KiB
C++
Raw Normal View History

new file: .circleci/config.yml 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
2020-01-04 14:21:38 +00:00
#include "tests.h"
TEST_CASE("parsing - comments")
new file: .circleci/config.yml 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
2020-01-04 14:21:38 +00:00
{
parsing_should_succeed(
FILE_LINE_ARGS,
S(R"(
new file: .circleci/config.yml 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
2020-01-04 14:21:38 +00:00
# This is a full-line comment
key = "value" # This is a comment at the end of a line
another = "# This is not a comment"
)"sv),
[](table&& tbl) noexcept
{
CHECK(tbl.size() == 2);
CHECK(tbl[S("key")] == S("value"sv));
CHECK(tbl[S("another")] == S("# This is not a comment"sv));
}
);
parsing_should_succeed(
FILE_LINE_ARGS,
S(R"(# this = "looks like a KVP but is commented out)"sv),
[](table&& tbl) noexcept
{
CHECK(tbl.size() == 0);
}
);
if constexpr (TOML_LANG_AT_LEAST(1, 0, 0))
{
// toml/issues/567 (disallow non-TAB control characters in comments)
// 00 - 08
parsing_should_fail(FILE_LINE_ARGS, S("# \u0000"sv));
parsing_should_fail(FILE_LINE_ARGS, S("# \u0001"sv));
parsing_should_fail(FILE_LINE_ARGS, S("# \u0002"sv));
parsing_should_fail(FILE_LINE_ARGS, S("# \u0003"sv));
parsing_should_fail(FILE_LINE_ARGS, S("# \u0004"sv));
parsing_should_fail(FILE_LINE_ARGS, S("# \u0005"sv));
parsing_should_fail(FILE_LINE_ARGS, S("# \u0006"sv));
parsing_should_fail(FILE_LINE_ARGS, S("# \u0007"sv));
parsing_should_fail(FILE_LINE_ARGS, S("# \u0008"sv));
// skip tab and line breaks (real and otherwise)
// \u0009 is \t
// \u000A is \n
// \u000B is \v (vertical tab)
// \u000C is \f (form feed)
// \u000D is \r
// 0E - 1F
parsing_should_fail(FILE_LINE_ARGS, S("# \u000E"sv));
parsing_should_fail(FILE_LINE_ARGS, S("# \u000F"sv));
parsing_should_fail(FILE_LINE_ARGS, S("# \u0010"sv));
parsing_should_fail(FILE_LINE_ARGS, S("# \u0011"sv));
parsing_should_fail(FILE_LINE_ARGS, S("# \u0012"sv));
parsing_should_fail(FILE_LINE_ARGS, S("# \u0013"sv));
parsing_should_fail(FILE_LINE_ARGS, S("# \u0014"sv));
parsing_should_fail(FILE_LINE_ARGS, S("# \u0015"sv));
parsing_should_fail(FILE_LINE_ARGS, S("# \u0016"sv));
parsing_should_fail(FILE_LINE_ARGS, S("# \u0017"sv));
parsing_should_fail(FILE_LINE_ARGS, S("# \u0018"sv));
parsing_should_fail(FILE_LINE_ARGS, S("# \u0019"sv));
parsing_should_fail(FILE_LINE_ARGS, S("# \u001A"sv));
parsing_should_fail(FILE_LINE_ARGS, S("# \u001B"sv));
parsing_should_fail(FILE_LINE_ARGS, S("# \u001C"sv));
parsing_should_fail(FILE_LINE_ARGS, S("# \u001D"sv));
parsing_should_fail(FILE_LINE_ARGS, S("# \u001E"sv));
parsing_should_fail(FILE_LINE_ARGS, S("# \u001F"sv));
// 7F
parsing_should_fail(FILE_LINE_ARGS, S("# \u007F"sv));
}
else
{
parsing_should_succeed(FILE_LINE_ARGS, S(
"## 00 - 08"
"# \u0000 "
"# \u0001 "
"# \u0002 "
"# \u0003 "
"# \u0004 "
"# \u0005 "
"# \u0006 "
"# \u0007 "
"# \u0008 "
"## 0A - 1F"
"# \u000A "
"# \u000B "
"# \u000C "
"# \u000D "
"# \u000E "
"# \u000F "
"# \u0010 "
"# \u0011 "
"# \u0012 "
"# \u0013 "
"# \u0014 "
"# \u0015 "
"# \u0016 "
"# \u0017 "
"# \u0018 "
"# \u0019 "
"# \u001A "
"# \u001B "
"# \u001C "
"# \u001D "
"# \u001E "
"# \u001F "
"## 7F "
"# \u007F "sv
));
}
new file: .circleci/config.yml 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
2020-01-04 14:21:38 +00:00
}