mirror of
https://github.com/marzer/tomlplusplus.git
synced 2024-09-15 15:13:21 +00:00
fixed array iterator conversion error (closes #67)
also removed superfluous newline when print ing a table (closes #68)
This commit is contained in:
parent
30b756f993
commit
5f3e01f71c
@ -12,6 +12,8 @@ TOML_IMPL_NAMESPACE_START
|
||||
class TOML_TRIVIAL_ABI array_iterator final
|
||||
{
|
||||
private:
|
||||
template <bool C>
|
||||
friend class array_iterator;
|
||||
friend class TOML_NAMESPACE::array;
|
||||
|
||||
using raw_mutable_iterator = std::vector<std::unique_ptr<node>>::iterator;
|
||||
|
@ -301,7 +301,6 @@ TOML_NAMESPACE_START
|
||||
{
|
||||
base::decrease_indent(); // so root kvps and tables have the same indent
|
||||
print(tbl);
|
||||
base::print_newline();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -21,6 +21,8 @@ TOML_IMPL_NAMESPACE_START
|
||||
class table_iterator final
|
||||
{
|
||||
private:
|
||||
template <bool C>
|
||||
friend class table_iterator;
|
||||
friend class TOML_NAMESPACE::table;
|
||||
|
||||
using proxy_type = table_proxy_pair<IsConst>;
|
||||
|
@ -411,8 +411,7 @@ TEST_CASE("tables - printing")
|
||||
{
|
||||
static constexpr auto some_toml = R"(val1 = 1
|
||||
val2 = 2
|
||||
val3 = 3
|
||||
)"sv; //new line at end!
|
||||
val3 = 3)"sv;
|
||||
|
||||
CHECK(to_string(some_toml) == some_toml);
|
||||
}
|
||||
@ -421,8 +420,7 @@ val3 = 3
|
||||
static constexpr auto some_toml = R"([a_table]
|
||||
a = 1
|
||||
b = 2
|
||||
c = 3
|
||||
)"sv; //new line at end!
|
||||
c = 3)"sv;
|
||||
|
||||
CHECK(to_string(some_toml) == some_toml);
|
||||
}
|
||||
@ -435,8 +433,7 @@ val3 = 3
|
||||
[a_table]
|
||||
a = 1
|
||||
b = 2
|
||||
c = 3
|
||||
)"sv; //new line at end!
|
||||
c = 3)"sv;
|
||||
|
||||
CHECK(to_string(some_toml) == some_toml);
|
||||
}
|
||||
|
@ -9,10 +9,8 @@
|
||||
|
||||
TEST_CASE("user feedback")
|
||||
{
|
||||
SECTION("feedback - github/issues/49")
|
||||
SECTION("github/issues/49") // https://github.com/marzer/tomlplusplus/issues/49#issuecomment-664428571
|
||||
{
|
||||
// see: https://github.com/marzer/tomlplusplus/issues/49#issuecomment-664428571
|
||||
|
||||
toml::table t1;
|
||||
t1.insert_or_assign("bar1", toml::array{ 1, 2, 3 });
|
||||
CHECK(t1 == toml::table{{
|
||||
@ -88,10 +86,8 @@ TEST_CASE("user feedback")
|
||||
}});
|
||||
}
|
||||
|
||||
SECTION("feedback - github/issues/65")
|
||||
SECTION("github/issues/65") // https://github.com/marzer/tomlplusplus/issues/65
|
||||
{
|
||||
// see: https://github.com/marzer/tomlplusplus/issues/65
|
||||
|
||||
// these test a number of things
|
||||
// - a comment at EOF
|
||||
// - a malformed UTF-8 sequence in a comment
|
||||
@ -113,5 +109,32 @@ TEST_CASE("user feedback")
|
||||
R"(t =[ 9, 2, 1,"r", 9999999999999999999999999999999999999999999999999999999999999995.0 ])"
|
||||
);
|
||||
}
|
||||
|
||||
SECTION("github/issues/67") // https://github.com/marzer/tomlplusplus/issues/67
|
||||
{
|
||||
const auto data = R"(array=["v1", "v2", "v3"])"sv;
|
||||
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
SECTION("github/issues/68") // https://github.com/marzer/tomlplusplus/issues/68
|
||||
{
|
||||
const auto data = R"(array=["v1", "v2", "v3"])"sv;
|
||||
parsing_should_succeed(FILE_LINE_ARGS, data, [](auto&& table)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << table;
|
||||
CHECK(ss.str() == "array = [ 'v1', 'v2', 'v3' ]"sv);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
5
toml.hpp
5
toml.hpp
@ -3410,6 +3410,8 @@ TOML_IMPL_NAMESPACE_START
|
||||
class TOML_TRIVIAL_ABI array_iterator final
|
||||
{
|
||||
private:
|
||||
template <bool C>
|
||||
friend class array_iterator;
|
||||
friend class TOML_NAMESPACE::array;
|
||||
|
||||
using raw_mutable_iterator = std::vector<std::unique_ptr<node>>::iterator;
|
||||
@ -3994,6 +3996,8 @@ TOML_IMPL_NAMESPACE_START
|
||||
class table_iterator final
|
||||
{
|
||||
private:
|
||||
template <bool C>
|
||||
friend class table_iterator;
|
||||
friend class TOML_NAMESPACE::table;
|
||||
|
||||
using proxy_type = table_proxy_pair<IsConst>;
|
||||
@ -6402,7 +6406,6 @@ TOML_NAMESPACE_START
|
||||
{
|
||||
base::decrease_indent(); // so root kvps and tables have the same indent
|
||||
print(tbl);
|
||||
base::print_newline();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user