mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-17 09:08:08 +08:00
style: make hint messages clearer
This commit is contained in:
@@ -1431,7 +1431,7 @@ result<value_t, std::string> guess_number_type(const location<Container>& l)
|
||||
{
|
||||
return err(format_underline("[error] bad offset: should be [+-]HH:MM or Z",
|
||||
{{std::addressof(loc), "[+-]HH:MM or Z"}},
|
||||
{"OK: +09:00, -05:30", "NG: +9:00, -5:30"}));
|
||||
{"pass: +09:00, -05:30", "fail: +9:00, -5:30"}));
|
||||
}
|
||||
return ok(value_t::LocalDatetime);
|
||||
}
|
||||
@@ -1451,15 +1451,15 @@ result<value_t, std::string> guess_number_type(const location<Container>& l)
|
||||
{
|
||||
return err(format_underline("[error] bad time: should be HH:MM:SS.subsec",
|
||||
{{std::addressof(loc), "HH:MM:SS.subsec"}},
|
||||
{"OK: 1979-05-27T07:32:00, 1979-05-27 07:32:00.999999",
|
||||
"NG: 1979-05-27T7:32:00, 1979-05-27 7:32"}));
|
||||
{"pass: 1979-05-27T07:32:00, 1979-05-27 07:32:00.999999",
|
||||
"fail: 1979-05-27T7:32:00, 1979-05-27 17:32"}));
|
||||
}
|
||||
if('0' <= c && c <= '9')
|
||||
{
|
||||
return err(format_underline("[error] bad time: missing T",
|
||||
{{std::addressof(loc), "T or space required here"}},
|
||||
{"OK: 1979-05-27T07:32:00, 1979-05-27 07:32:00.999999",
|
||||
"NG: 1979-05-27T7:32:00, 1979-05-27 7:32"}));
|
||||
{"pass: 1979-05-27T07:32:00, 1979-05-27 07:32:00.999999",
|
||||
"fail: 1979-05-27T7:32:00, 1979-05-27 7:32"}));
|
||||
}
|
||||
if(c == ' ' && std::next(loc.iter()) != loc.end() &&
|
||||
('0' <= *std::next(loc.iter()) && *std::next(loc.iter())<= '9'))
|
||||
@@ -1467,8 +1467,8 @@ result<value_t, std::string> guess_number_type(const location<Container>& l)
|
||||
loc.advance();
|
||||
return err(format_underline("[error] bad time: should be HH:MM:SS.subsec",
|
||||
{{std::addressof(loc), "HH:MM:SS.subsec"}},
|
||||
{"OK: 1979-05-27T07:32:00, 1979-05-27 07:32:00.999999",
|
||||
"NG: 1979-05-27T7:32:00, 1979-05-27 7:32"}));
|
||||
{"pass: 1979-05-27T07:32:00, 1979-05-27 07:32:00.999999",
|
||||
"fail: 1979-05-27T7:32:00, 1979-05-27 7:32"}));
|
||||
}
|
||||
}
|
||||
return ok(value_t::LocalDate);
|
||||
@@ -1484,8 +1484,8 @@ result<value_t, std::string> guess_number_type(const location<Container>& l)
|
||||
{
|
||||
return err(format_underline("[error] bad float: `_` should be surrounded by digits",
|
||||
{{std::addressof(loc), "here"}},
|
||||
{"OK: +1.0, -2e-2, 3.141_592_653_589, inf, nan",
|
||||
"NG: .0, 1., _1.0, 1.0_, 1_.0, 1.0__0"}));
|
||||
{"pass: +1.0, -2e-2, 3.141_592_653_589, inf, nan",
|
||||
"fail: .0, 1., _1.0, 1.0_, 1_.0, 1.0__0"}));
|
||||
}
|
||||
return ok(value_t::Float);
|
||||
}
|
||||
@@ -1500,8 +1500,8 @@ result<value_t, std::string> guess_number_type(const location<Container>& l)
|
||||
{
|
||||
return err(format_underline("[error] bad integer: `_` should be surrounded by digits",
|
||||
{{std::addressof(loc), "here"}},
|
||||
{"OK: -42, 1_000, 1_2_3_4_5, 0xC0FFEE, 0b0010, 0o755",
|
||||
"NG: 1__000, 0123"}));
|
||||
{"pass: -42, 1_000, 1_2_3_4_5, 0xC0FFEE, 0b0010, 0o755",
|
||||
"fail: 1__000, 0123"}));
|
||||
}
|
||||
if('0' <= c && c <= '9')
|
||||
{
|
||||
@@ -1509,22 +1509,22 @@ result<value_t, std::string> guess_number_type(const location<Container>& l)
|
||||
loc.retrace();
|
||||
return err(format_underline("[error] bad integer: leading zero",
|
||||
{{std::addressof(loc), "here"}},
|
||||
{"OK: -42, 1_000, 1_2_3_4_5, 0xC0FFEE, 0b0010, 0o755",
|
||||
"NG: 1__000, 0123"}));
|
||||
{"pass: -42, 1_000, 1_2_3_4_5, 0xC0FFEE, 0b0010, 0o755",
|
||||
"fail: 1__000, 0123"}));
|
||||
}
|
||||
if(c == ':' || c == '-')
|
||||
{
|
||||
return err(format_underline("[error] bad datetime: invalid format",
|
||||
{{std::addressof(loc), "here"}},
|
||||
{"OK: 1979-05-27T07:32:00-07:00, 1979-05-27 07:32:00.999999Z",
|
||||
"NG: 1979-05-27T7:32:00-7:00, 1979-05-27 7:32-00:30"}));
|
||||
{"pass: 1979-05-27T07:32:00-07:00, 1979-05-27 07:32:00.999999Z",
|
||||
"fail: 1979-05-27T7:32:00-7:00, 1979-05-27 7:32-00:30"}));
|
||||
}
|
||||
if(c == '.' || c == 'e' || c == 'E')
|
||||
{
|
||||
return err(format_underline("[error] bad float: invalid format",
|
||||
{{std::addressof(loc), "here"}},
|
||||
{"OK: +1.0, -2e-2, 3.141_592_653_589, inf, nan",
|
||||
"NG: .0, 1., _1.0, 1.0_, 1_.0, 1.0__0"}));
|
||||
{"pass: +1.0, -2e-2, 3.141_592_653_589, inf, nan",
|
||||
"fail: .0, 1., _1.0, 1.0_, 1_.0, 1.0__0"}));
|
||||
}
|
||||
}
|
||||
return ok(value_t::Integer);
|
||||
@@ -1533,15 +1533,15 @@ result<value_t, std::string> guess_number_type(const location<Container>& l)
|
||||
{
|
||||
return err(format_underline("[error] bad float: invalid format",
|
||||
{{std::addressof(loc), "integer part required before this"}},
|
||||
{"OK: +1.0, -2e-2, 3.141_592_653_589, inf, nan",
|
||||
"NG: .0, 1., _1.0, 1.0_, 1_.0, 1.0__0"}));
|
||||
{"pass: +1.0, -2e-2, 3.141_592_653_589, inf, nan",
|
||||
"fail: .0, 1., _1.0, 1.0_, 1_.0, 1.0__0"}));
|
||||
}
|
||||
if(loc.iter() != loc.end() && *loc.iter() == '_')
|
||||
{
|
||||
return err(format_underline("[error] bad number: `_` should be surrounded by digits",
|
||||
{{std::addressof(loc), "`_` is not surrounded by digits"}},
|
||||
{"OK: -42, 1_000, 1_2_3_4_5, 0xC0FFEE, 0b0010, 0o755",
|
||||
"NG: 1__000, 0123"}));
|
||||
{"pass: -42, 1_000, 1_2_3_4_5, 0xC0FFEE, 0b0010, 0o755",
|
||||
"fail: 1__000, 0123"}));
|
||||
}
|
||||
return err(format_underline("[error] bad format: unknown value appeared",
|
||||
{{std::addressof(loc), "here"}}));
|
||||
|
Reference in New Issue
Block a user