2020-07-27 22:04:52 +00:00
|
|
|
// This file is a part of toml++ and is subject to the the terms of the MIT license.
|
2021-01-02 15:48:47 +00:00
|
|
|
// Copyright (c) Mark Gillard <mark.gillard@outlook.com.au>
|
2020-07-27 22:04:52 +00:00
|
|
|
// See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text.
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
#include "tests.h"
|
|
|
|
|
|
|
|
// this file is about testing user misc. repros submitted via github issues, et cetera.
|
|
|
|
|
2020-10-09 20:49:06 +00:00
|
|
|
TEST_CASE("user feedback")
|
2020-07-27 22:04:52 +00:00
|
|
|
{
|
2022-05-30 18:57:15 +00:00
|
|
|
SECTION("tomlplusplus/issues/49") // https://github.com/marzer/tomlplusplus/issues/49#issuecomment-664428571
|
2020-07-27 22:04:52 +00:00
|
|
|
{
|
|
|
|
toml::table t1;
|
|
|
|
t1.insert_or_assign("bar1", toml::array{ 1, 2, 3 });
|
2021-10-26 18:03:56 +00:00
|
|
|
CHECK(t1 == toml::table{ { "bar1"sv, toml::array{ 1, 2, 3 } } });
|
2020-07-27 22:04:52 +00:00
|
|
|
|
|
|
|
t1.insert_or_assign("foo1", *t1.get("bar1"));
|
2021-10-26 18:03:56 +00:00
|
|
|
CHECK(t1 == toml::table{ { "bar1"sv, toml::array{ 1, 2, 3 } }, { "foo1"sv, toml::array{ 1, 2, 3 } } });
|
2020-07-27 22:04:52 +00:00
|
|
|
|
2021-10-26 13:49:23 +00:00
|
|
|
// t1["foo1"] = t1["bar1"]; // does nothing, should this fail to compile?
|
|
|
|
// - yes -
|
2020-07-27 22:04:52 +00:00
|
|
|
|
|
|
|
//*t1["foo1"].node() = *t1["bar1"].node(); // compile failure; copying node_view would be a bad thing
|
|
|
|
// - correct; copying toml::node directly like that is impossible b.c. it's an abstract base class-
|
|
|
|
|
|
|
|
toml::array* array1 = t1["foo1"].node()->as_array();
|
|
|
|
array1->push_back(4);
|
2021-10-26 18:03:56 +00:00
|
|
|
CHECK(t1 == toml::table{ { "bar1"sv, toml::array{ 1, 2, 3 } }, { "foo1"sv, toml::array{ 1, 2, 3, 4 } } });
|
2020-07-27 22:04:52 +00:00
|
|
|
|
|
|
|
t1.insert_or_assign("foo3", t1["foo1"]);
|
2021-10-26 13:49:23 +00:00
|
|
|
CHECK(t1
|
2021-10-26 18:03:56 +00:00
|
|
|
== toml::table{ { "bar1"sv, toml::array{ 1, 2, 3 } },
|
|
|
|
{ "foo1"sv, toml::array{ 1, 2, 3, 4 } },
|
|
|
|
{ "foo3"sv, toml::array{ 1, 2, 3, 4 } } });
|
2020-07-27 22:04:52 +00:00
|
|
|
|
|
|
|
t1.insert_or_assign("foo2", *t1["foo1"].node());
|
2021-10-26 13:49:23 +00:00
|
|
|
CHECK(t1
|
2021-10-26 18:03:56 +00:00
|
|
|
== toml::table{ { "bar1"sv, toml::array{ 1, 2, 3 } },
|
|
|
|
{ "foo1"sv, toml::array{ 1, 2, 3, 4 } },
|
|
|
|
{ "foo2"sv, toml::array{ 1, 2, 3, 4 } },
|
|
|
|
{ "foo3"sv, toml::array{ 1, 2, 3, 4 } } });
|
2020-07-27 22:04:52 +00:00
|
|
|
|
|
|
|
toml::array* array2 = t1["foo2"].node()->as_array();
|
|
|
|
array2->push_back("wrench");
|
2021-10-26 13:49:23 +00:00
|
|
|
CHECK(t1
|
2021-10-26 18:03:56 +00:00
|
|
|
== toml::table{ { "bar1"sv, toml::array{ 1, 2, 3 } },
|
|
|
|
{ "foo1"sv, toml::array{ 1, 2, 3, 4 } },
|
|
|
|
{ "foo2"sv, toml::array{ 1, 2, 3, 4, "wrench" } },
|
|
|
|
{ "foo3"sv, toml::array{ 1, 2, 3, 4 } } });
|
2020-07-27 22:04:52 +00:00
|
|
|
|
|
|
|
toml::table t2 = t1;
|
|
|
|
CHECK(t2 == t1);
|
|
|
|
CHECK(&t2 != &t1);
|
|
|
|
|
2021-10-26 13:49:23 +00:00
|
|
|
// t2.emplace("bar", toml::array{6, 7}); // fails to compile? not sure what I did wrong
|
|
|
|
// - it should be this: -
|
2020-07-27 22:04:52 +00:00
|
|
|
t2.emplace<toml::array>("bar", 6, 7);
|
2021-10-26 13:49:23 +00:00
|
|
|
CHECK(t2
|
2021-10-26 18:03:56 +00:00
|
|
|
== toml::table{ { "bar"sv, toml::array{ 6, 7 } },
|
|
|
|
{ "bar1"sv, toml::array{ 1, 2, 3 } },
|
|
|
|
{ "foo1"sv, toml::array{ 1, 2, 3, 4 } },
|
|
|
|
{ "foo2"sv, toml::array{ 1, 2, 3, 4, "wrench" } },
|
|
|
|
{ "foo3"sv, toml::array{ 1, 2, 3, 4 } } });
|
2020-07-27 22:04:52 +00:00
|
|
|
|
|
|
|
t2.insert_or_assign("bar2", toml::array{ 6, 7 });
|
2021-10-26 13:49:23 +00:00
|
|
|
CHECK(t2
|
2021-10-26 18:03:56 +00:00
|
|
|
== toml::table{ { "bar"sv, toml::array{ 6, 7 } },
|
|
|
|
{ "bar1"sv, toml::array{ 1, 2, 3 } },
|
|
|
|
{ "bar2"sv, toml::array{ 6, 7 } },
|
|
|
|
{ "foo1"sv, toml::array{ 1, 2, 3, 4 } },
|
|
|
|
{ "foo2"sv, toml::array{ 1, 2, 3, 4, "wrench" } },
|
|
|
|
{ "foo3"sv, toml::array{ 1, 2, 3, 4 } } });
|
2020-07-27 22:04:52 +00:00
|
|
|
}
|
2020-08-02 09:20:41 +00:00
|
|
|
|
2022-05-30 18:57:15 +00:00
|
|
|
SECTION("tomlplusplus/issues/65") // https://github.com/marzer/tomlplusplus/issues/65
|
2020-08-02 09:20:41 +00:00
|
|
|
{
|
2020-10-10 08:45:53 +00:00
|
|
|
// these test a number of things
|
2020-10-09 20:49:06 +00:00
|
|
|
// - a comment at EOF
|
2020-10-10 08:45:53 +00:00
|
|
|
// - a malformed UTF-8 sequence in a comment
|
|
|
|
// - a malformed UTF-8 sequence during a KVP
|
|
|
|
// - overlong numeric literals
|
|
|
|
// all should fail to parse, but correctly issue an error (not crash!)
|
2021-10-26 13:49:23 +00:00
|
|
|
|
2020-10-09 20:49:06 +00:00
|
|
|
parsing_should_fail(FILE_LINE_ARGS, "#\xf1\x63");
|
2020-10-09 21:30:12 +00:00
|
|
|
parsing_should_fail(FILE_LINE_ARGS, "1= 0x6cA#+\xf1");
|
2020-10-10 08:45:53 +00:00
|
|
|
parsing_should_fail(FILE_LINE_ARGS, "p=06:06:06#\x0b\xff");
|
2021-10-26 13:49:23 +00:00
|
|
|
parsing_should_fail(
|
|
|
|
FILE_LINE_ARGS,
|
|
|
|
"''''d' 't' '+o\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"
|
2020-10-10 08:45:53 +00:00
|
|
|
"\x0c\x0c\x0c\x0c\x0c\r\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"
|
|
|
|
"\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"
|
|
|
|
"\x0c\x0c\x0c\x0c\x0c\x0c\x0cop1\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"
|
|
|
|
"\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"
|
2021-10-26 13:49:23 +00:00
|
|
|
"\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c' 'ml'\n\n%\x87");
|
|
|
|
parsing_should_fail(
|
|
|
|
FILE_LINE_ARGS,
|
2022-01-06 11:26:01 +00:00
|
|
|
R"(t =[ 9, 2, 1,"r", 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0 ])");
|
2020-08-02 09:20:41 +00:00
|
|
|
}
|
2020-10-22 11:34:01 +00:00
|
|
|
|
2022-05-30 18:57:15 +00:00
|
|
|
SECTION("tomlplusplus/issues/67") // https://github.com/marzer/tomlplusplus/issues/67
|
2020-10-22 11:34:01 +00:00
|
|
|
{
|
|
|
|
const auto data = R"(array=["v1", "v2", "v3"])"sv;
|
|
|
|
|
2021-10-26 13:49:23 +00:00
|
|
|
parsing_should_succeed(FILE_LINE_ARGS,
|
|
|
|
data,
|
|
|
|
[](auto&& table)
|
|
|
|
{
|
|
|
|
auto arr = table["array"].as_array();
|
|
|
|
for (auto it = arr->cbegin(); it != arr->cend();)
|
|
|
|
if (it->value_or(std::string_view{}) == "v2"sv)
|
|
|
|
it = arr->erase(it);
|
|
|
|
else
|
|
|
|
++it;
|
|
|
|
CHECK(arr->size() == 2);
|
|
|
|
});
|
2020-10-22 11:34:01 +00:00
|
|
|
}
|
|
|
|
|
2022-05-30 18:57:15 +00:00
|
|
|
SECTION("tomlplusplus/issues/68") // https://github.com/marzer/tomlplusplus/issues/68
|
2020-10-22 11:34:01 +00:00
|
|
|
{
|
|
|
|
const auto data = R"(array=["v1", "v2", "v3"])"sv;
|
2021-10-26 13:49:23 +00:00
|
|
|
parsing_should_succeed(FILE_LINE_ARGS,
|
|
|
|
data,
|
|
|
|
[](auto&& table)
|
|
|
|
{
|
|
|
|
std::stringstream ss;
|
|
|
|
ss << table;
|
|
|
|
CHECK(ss.str() == "array = [ 'v1', 'v2', 'v3' ]"sv);
|
|
|
|
});
|
2020-10-22 11:34:01 +00:00
|
|
|
}
|
2020-10-22 13:25:26 +00:00
|
|
|
|
2022-05-30 18:57:15 +00:00
|
|
|
SECTION("tomlplusplus/issues/69") // https://github.com/marzer/tomlplusplus/issues/69
|
2020-10-22 13:25:26 +00:00
|
|
|
{
|
|
|
|
using namespace toml::literals; // should compile without namespace ambiguity
|
|
|
|
auto table = "[table]\nkey=\"value\""_toml;
|
|
|
|
}
|
2021-01-07 10:06:26 +00:00
|
|
|
|
2022-05-30 18:57:15 +00:00
|
|
|
SECTION("tomlplusplus/pull/80") // https://github.com/marzer/tomlplusplus/pull/80
|
2021-01-07 10:06:26 +00:00
|
|
|
{
|
|
|
|
const auto data = R"(
|
|
|
|
a = { "key" = 1 } # inline table
|
|
|
|
b = [] # array value
|
|
|
|
[[c]] # array-of-tables with a single, empty table element
|
|
|
|
)"sv;
|
|
|
|
|
2021-10-26 13:49:23 +00:00
|
|
|
parsing_should_succeed(FILE_LINE_ARGS,
|
|
|
|
data,
|
|
|
|
[](auto&& table)
|
|
|
|
{
|
|
|
|
std::stringstream ss;
|
|
|
|
ss << table;
|
|
|
|
CHECK(ss.str() == R"(a = { key = 1 }
|
2021-01-07 10:06:26 +00:00
|
|
|
b = []
|
|
|
|
|
|
|
|
[[c]])"sv);
|
2021-10-26 13:49:23 +00:00
|
|
|
});
|
2021-01-07 10:06:26 +00:00
|
|
|
}
|
|
|
|
|
2022-05-30 18:57:15 +00:00
|
|
|
SECTION("tomlplusplus/issues/100") // https://github.com/marzer/tomlplusplus/issues/100
|
2021-05-17 21:32:35 +00:00
|
|
|
{
|
|
|
|
// this tests for two separate things that should fail gracefully, not crash:
|
|
|
|
// 1. pathologically-nested inputs
|
|
|
|
// 2. a particular sequence of malformed UTF-8
|
|
|
|
|
|
|
|
parsing_should_fail(FILE_LINE_ARGS, "fl =[ [[[[[[[[[[[[[[[\x36\x80\x86\x00\x00\x00\x2D\x36\x9F\x20\x00"sv);
|
|
|
|
|
|
|
|
std::string s(2048_sz, '[');
|
|
|
|
constexpr auto start = "fl =[ "sv;
|
|
|
|
memcpy(s.data(), start.data(), start.length());
|
|
|
|
parsing_should_fail(FILE_LINE_ARGS, std::string_view{ s });
|
|
|
|
}
|
|
|
|
|
2022-05-30 18:57:15 +00:00
|
|
|
SECTION("tomlplusplus/issues/112") // https://github.com/marzer/tomlplusplus/issues/112
|
2021-09-04 09:24:47 +00:00
|
|
|
{
|
2021-10-26 13:49:23 +00:00
|
|
|
parsing_should_fail(FILE_LINE_ARGS,
|
|
|
|
R"(
|
2021-09-04 09:24:47 +00:00
|
|
|
[a.b.c.d]
|
|
|
|
u = 6
|
|
|
|
[a]
|
|
|
|
b.t = 8
|
|
|
|
[a.b] # should cause redefinition error here
|
|
|
|
u = 0
|
2021-10-26 13:49:23 +00:00
|
|
|
)",
|
|
|
|
6);
|
2021-09-04 09:24:47 +00:00
|
|
|
|
2021-10-26 13:49:23 +00:00
|
|
|
parsing_should_fail(FILE_LINE_ARGS,
|
|
|
|
R"(
|
2021-09-04 09:24:47 +00:00
|
|
|
[a]
|
|
|
|
b.t = 8
|
|
|
|
[a.b] # should cause redefinition error here
|
|
|
|
u = 0
|
2021-10-26 13:49:23 +00:00
|
|
|
)",
|
|
|
|
4);
|
2021-09-04 09:24:47 +00:00
|
|
|
}
|
2022-01-04 14:23:45 +00:00
|
|
|
|
2022-05-30 18:57:15 +00:00
|
|
|
SECTION("tomlplusplus/issues/125") // https://github.com/marzer/tomlplusplus/issues/125
|
2022-01-04 14:23:45 +00:00
|
|
|
{
|
|
|
|
parse_expected_value(FILE_LINE_ARGS, R"("\u0800")"sv, "\xE0\xA0\x80"sv);
|
|
|
|
parse_expected_value(FILE_LINE_ARGS, R"("\u7840")"sv, "\xE7\xA1\x80"sv);
|
|
|
|
parse_expected_value(FILE_LINE_ARGS, R"("\uAA23")"sv, "\xEA\xA8\xA3"sv);
|
|
|
|
parse_expected_value(FILE_LINE_ARGS, R"("\uA928")"sv, "\xEA\xA4\xA8"sv);
|
|
|
|
parse_expected_value(FILE_LINE_ARGS, R"("\u9CBF")"sv, "\xE9\xB2\xBF"sv);
|
|
|
|
parse_expected_value(FILE_LINE_ARGS, R"("\u2247")"sv, "\xE2\x89\x87"sv);
|
|
|
|
parse_expected_value(FILE_LINE_ARGS, R"("\u13D9")"sv, "\xE1\x8F\x99"sv);
|
|
|
|
parse_expected_value(FILE_LINE_ARGS, R"("\u69FC")"sv, "\xE6\xA7\xBC"sv);
|
|
|
|
parse_expected_value(FILE_LINE_ARGS, R"("\u8DE5")"sv, "\xE8\xB7\xA5"sv);
|
|
|
|
parse_expected_value(FILE_LINE_ARGS, R"("\u699C")"sv, "\xE6\xA6\x9C"sv);
|
|
|
|
parse_expected_value(FILE_LINE_ARGS, R"("\u8CD4")"sv, "\xE8\xB3\x94"sv);
|
|
|
|
parse_expected_value(FILE_LINE_ARGS, R"("\u4ED4")"sv, "\xE4\xBB\x94"sv);
|
|
|
|
parse_expected_value(FILE_LINE_ARGS, R"("\u2597")"sv, "\xE2\x96\x97"sv);
|
|
|
|
}
|
|
|
|
|
2022-05-30 18:57:15 +00:00
|
|
|
SECTION("tomlplusplus/issues/127") // https://github.com/marzer/tomlplusplus/issues/127
|
2022-01-04 14:23:45 +00:00
|
|
|
{
|
|
|
|
parse_expected_value(FILE_LINE_ARGS,
|
|
|
|
"12:34:56.11122233345678"sv,
|
|
|
|
toml::time{
|
|
|
|
12,
|
|
|
|
34,
|
|
|
|
56,
|
|
|
|
111222333u // should truncate the .45678 part
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-05-30 18:57:15 +00:00
|
|
|
SECTION("tomlplusplus/issues/128") // https://github.com/marzer/tomlplusplus/issues/128
|
2022-01-04 14:23:45 +00:00
|
|
|
{
|
|
|
|
parsing_should_fail(FILE_LINE_ARGS, "\f"sv);
|
|
|
|
parsing_should_fail(FILE_LINE_ARGS, "\v"sv);
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, " "sv);
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, "\t"sv);
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, "\n"sv);
|
|
|
|
}
|
2022-01-05 08:58:24 +00:00
|
|
|
|
2022-05-30 18:57:15 +00:00
|
|
|
SECTION("tomlplusplus/issues/129") // https://github.com/marzer/tomlplusplus/issues/129
|
2022-01-05 08:58:24 +00:00
|
|
|
{
|
|
|
|
parsing_should_fail(FILE_LINE_ARGS, R"(
|
|
|
|
hex = 0x
|
|
|
|
oct = 0o
|
|
|
|
bin = 0b
|
|
|
|
)"sv);
|
|
|
|
}
|
|
|
|
|
2022-05-30 18:57:15 +00:00
|
|
|
SECTION("tomlplusplus/issues/130") // https://github.com/marzer/tomlplusplus/issues/130
|
2022-01-05 08:58:24 +00:00
|
|
|
{
|
|
|
|
parse_expected_value(FILE_LINE_ARGS, "0400-01-01 00:00:00"sv, toml::date_time{ { 400, 1, 1 }, { 0, 0, 0 } });
|
|
|
|
parse_expected_value(FILE_LINE_ARGS, "0400-01-01 "sv, toml::date{ 400, 1, 1 });
|
|
|
|
parse_expected_value(FILE_LINE_ARGS, "0400-01-01T00:00:00"sv, toml::date_time{ { 400, 1, 1 }, { 0, 0, 0 } });
|
|
|
|
parse_expected_value(FILE_LINE_ARGS, "1000-01-01 00:00:00"sv, toml::date_time{ { 1000, 1, 1 }, { 0, 0, 0 } });
|
|
|
|
}
|
2022-01-05 14:47:00 +00:00
|
|
|
|
2022-05-30 18:57:15 +00:00
|
|
|
SECTION("tomlplusplus/issues/131") // https://github.com/marzer/tomlplusplus/issues/131
|
2022-01-05 14:47:00 +00:00
|
|
|
{
|
|
|
|
parsing_should_fail(FILE_LINE_ARGS, R"(
|
|
|
|
a={}
|
|
|
|
[a.b]
|
|
|
|
)"sv);
|
|
|
|
}
|
2022-01-05 16:10:50 +00:00
|
|
|
|
2022-05-30 18:57:15 +00:00
|
|
|
SECTION("tomlplusplus/issues/132") // https://github.com/marzer/tomlplusplus/issues/132
|
2022-01-05 16:10:50 +00:00
|
|
|
{
|
|
|
|
parsing_should_fail(FILE_LINE_ARGS, "#\r"sv);
|
|
|
|
}
|
2022-01-08 13:17:12 +00:00
|
|
|
|
2022-05-30 18:57:15 +00:00
|
|
|
SECTION("tomlplusplus/issues/134") // https://github.com/marzer/tomlplusplus/issues/134
|
2022-01-08 13:17:12 +00:00
|
|
|
{
|
|
|
|
// binary
|
|
|
|
parsing_should_fail(
|
|
|
|
FILE_LINE_ARGS,
|
|
|
|
"val = 0b11111111_11111111_11111111_11111111_11111111_11111111_11111111_11111111"sv); // uint64_t
|
|
|
|
// max
|
|
|
|
parsing_should_fail(
|
|
|
|
FILE_LINE_ARGS,
|
|
|
|
"val = 0b10000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000"sv); // int64_t
|
|
|
|
// max
|
|
|
|
// + 1
|
|
|
|
parse_expected_value(FILE_LINE_ARGS,
|
|
|
|
"0b01111111_11111111_11111111_11111111_11111111_11111111_11111111_11111111"sv,
|
|
|
|
INT64_MAX); // int64_t max
|
|
|
|
|
|
|
|
// octal
|
|
|
|
parsing_should_fail(FILE_LINE_ARGS, " val = 0o1777777777777777777777"sv); // uint64_t max
|
|
|
|
parsing_should_fail(FILE_LINE_ARGS, " val = 0o1000000000000000000000"sv); // int64_t max + 1
|
|
|
|
parse_expected_value(FILE_LINE_ARGS, " 0o0777777777777777777777"sv, INT64_MAX);
|
|
|
|
|
|
|
|
// decimal
|
|
|
|
parsing_should_fail(FILE_LINE_ARGS, " val = 100000000000000000000"sv);
|
|
|
|
parsing_should_fail(FILE_LINE_ARGS, " val = 18446744073709551615"sv); // uint64_t max
|
|
|
|
parsing_should_fail(FILE_LINE_ARGS, " val = 10000000000000000000"sv);
|
|
|
|
parsing_should_fail(FILE_LINE_ARGS, " val = 9999999999999999999"sv);
|
|
|
|
parsing_should_fail(FILE_LINE_ARGS, " val = 9223372036854775808"sv); // int64_t max + 1
|
|
|
|
parse_expected_value(FILE_LINE_ARGS, " 9223372036854775807"sv, INT64_MAX);
|
|
|
|
parse_expected_value(FILE_LINE_ARGS, " 1000000000000000000"sv, 1000000000000000000LL);
|
|
|
|
parse_expected_value(FILE_LINE_ARGS, " -1000000000000000000"sv, -1000000000000000000LL);
|
|
|
|
parse_expected_value(FILE_LINE_ARGS, " -9223372036854775808"sv, INT64_MIN);
|
|
|
|
parsing_should_fail(FILE_LINE_ARGS, " val = -9223372036854775809"sv); // int64_t min - 1
|
|
|
|
parsing_should_fail(FILE_LINE_ARGS, " val = -10000000000000000000"sv);
|
|
|
|
parsing_should_fail(FILE_LINE_ARGS, " val = -18446744073709551615"sv); // -(uint64_t max)
|
|
|
|
parsing_should_fail(FILE_LINE_ARGS, " val = -100000000000000000000"sv);
|
|
|
|
|
|
|
|
// hexadecimal
|
|
|
|
parsing_should_fail(FILE_LINE_ARGS, " val = 0xFFFFFFFFFFFFFFFF"sv); // uint64_t max
|
|
|
|
parsing_should_fail(FILE_LINE_ARGS, " val = 0x8000000000000000"sv); // int64_t max + 1
|
|
|
|
parse_expected_value(FILE_LINE_ARGS, " 0x7FFFFFFFFFFFFFFF"sv, INT64_MAX);
|
|
|
|
}
|
2022-01-09 11:01:56 +00:00
|
|
|
|
2022-05-30 18:57:15 +00:00
|
|
|
SECTION("tomlplusplus/issues/135") // https://github.com/marzer/tomlplusplus/issues/135
|
2022-01-09 11:01:56 +00:00
|
|
|
{
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, "0=0"sv);
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, "1=1"sv);
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, "2=2"sv);
|
|
|
|
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS,
|
|
|
|
"0=0\n"
|
|
|
|
"1=1\n"
|
|
|
|
"2=2\n"sv);
|
|
|
|
|
|
|
|
parsing_should_fail(FILE_LINE_ARGS,
|
|
|
|
"0=0\n"
|
|
|
|
"\u2000\u2000\n"
|
|
|
|
"1=1\n"
|
|
|
|
"2=2\n"sv);
|
|
|
|
}
|
2022-05-14 12:22:21 +00:00
|
|
|
|
2022-05-30 18:57:15 +00:00
|
|
|
SECTION("tomlplusplus/issues/152") // https://github.com/marzer/tomlplusplus/issues/152
|
2022-05-14 12:22:21 +00:00
|
|
|
{
|
|
|
|
// clang-format off
|
|
|
|
static constexpr auto data = R"([shaders.room_darker])" "\n"
|
|
|
|
R"(file = "room_darker.frag")" "\n"
|
|
|
|
R"(args = { n = "integer", ambientLightLevel = "float" })";
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS,
|
|
|
|
data,
|
|
|
|
[](auto&& tbl)
|
|
|
|
{
|
|
|
|
const auto check_location = [&](std::string_view path, auto line, auto col)
|
|
|
|
{
|
|
|
|
INFO("Checking source location of \""sv << path << "\""sv)
|
|
|
|
auto v = tbl.at_path(path);
|
|
|
|
REQUIRE(v.node());
|
|
|
|
CHECK(v.node()->source().begin.line == static_cast<toml::source_index>(line));
|
|
|
|
CHECK(v.node()->source().begin.column == static_cast<toml::source_index>(col));
|
|
|
|
};
|
|
|
|
|
|
|
|
check_location("shaders"sv, 1, 1);
|
|
|
|
check_location("shaders.room_darker"sv, 1, 1);
|
|
|
|
check_location("shaders.room_darker.file"sv, 2, 8);
|
|
|
|
check_location("shaders.room_darker.args"sv, 3, 8);
|
|
|
|
check_location("shaders.room_darker.args.n"sv, 3, 14);
|
|
|
|
check_location("shaders.room_darker.args.ambientLightLevel"sv, 3, 45);
|
|
|
|
});
|
|
|
|
}
|
2022-05-30 18:57:15 +00:00
|
|
|
|
|
|
|
SECTION("toml/issues/908") // https://github.com/toml-lang/toml/issues/908
|
|
|
|
{
|
|
|
|
parsing_should_fail(FILE_LINE_ARGS, R"(
|
|
|
|
a = [{ b = 1 }]
|
|
|
|
[a.c]
|
|
|
|
foo = 1
|
|
|
|
)"sv);
|
|
|
|
|
|
|
|
parsing_should_succeed(FILE_LINE_ARGS, R"(
|
|
|
|
[[a]]
|
|
|
|
b = 1
|
|
|
|
|
|
|
|
[a.c]
|
|
|
|
foo = 1
|
|
|
|
)"sv);
|
|
|
|
}
|
2020-08-02 09:20:41 +00:00
|
|
|
}
|