From 3477a7103c1e1f4a9041d1f27b2f66933f506435 Mon Sep 17 00:00:00 2001 From: bbgan <2893129936@qq.com> Date: Thu, 7 Dec 2023 14:06:13 +0800 Subject: [PATCH] fix skip_sapces_and_newline --- iguana/xml_util.hpp | 2 +- iguana/yaml_util.hpp | 2 +- test/test_xml.cpp | 23 +++++++++++++---------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/iguana/xml_util.hpp b/iguana/xml_util.hpp index fc703311..cd2df709 100644 --- a/iguana/xml_util.hpp +++ b/iguana/xml_util.hpp @@ -80,7 +80,7 @@ inline constexpr auto has_equal = [](uint64_t chunk) IGUANA__INLINE_LAMBDA { template IGUANA_INLINE void skip_sapces_and_newline(It &&it, It &&end) { - while (it != end && (*it < 33)) { + while (it != end && (static_cast(*it) < 33)) { ++it; } } diff --git a/iguana/yaml_util.hpp b/iguana/yaml_util.hpp index 00e44461..0f2be370 100644 --- a/iguana/yaml_util.hpp +++ b/iguana/yaml_util.hpp @@ -6,7 +6,7 @@ namespace iguana { // return true when it==end template IGUANA_INLINE bool skip_space_till_end(It &&it, It &&end) { - while (it != end && *it < 33) ++it; + while (it != end && (static_cast(*it) < 33)) ++it; return it == end; } diff --git a/test/test_xml.cpp b/test/test_xml.cpp index 2aac5f65..0d8a2830 100644 --- a/test/test_xml.cpp +++ b/test/test_xml.cpp @@ -3,11 +3,12 @@ #include #include #define DOCTEST_CONFIG_IMPLEMENT +#include +#include + #include "doctest.h" #include "iguana/xml_reader.hpp" #include "iguana/xml_writer.hpp" -#include -#include struct Owner_t { std::string ID; @@ -196,7 +197,7 @@ TEST_CASE("test some type") { CHECK(s.hasdescription == true); CHECK(s.c == 'X'); CHECK(*s.d_v == 3.14159); - CHECK(s.name == "John Doe"); + CHECK(s.name == "张三"); CHECK(s.addr == "123 Main St"); CHECK(s.status == enum_status::stop); }; @@ -216,7 +217,7 @@ TEST_CASE("test some type") { true X 3.14159 - John Doe + 张三 123 Main St 1 @@ -547,11 +548,12 @@ enum class Color { }; enum class Status { stop = 10, start }; namespace iguana { -template <> struct enum_value { +template <> +struct enum_value { constexpr static std::array value = {9999, -4, 10, 99, 7, 100000}; }; -} // namespace iguana +} // namespace iguana struct test_enum_t { Fruit a; Fruit b; @@ -564,7 +566,7 @@ struct test_enum_t { }; REFLECTION(test_enum_t, a, b, c, d, e, f, g, h); -#if defined(__clang__) || defined(_MSC_VER) || \ +#if defined(__clang__) || defined(_MSC_VER) || \ (defined(__GNUC__) && __GNUC__ > 8) TEST_CASE("test enum") { @@ -605,10 +607,11 @@ TEST_CASE("test enum") { enum class State { STOP = 10, START }; namespace iguana { -template <> struct enum_value { +template <> +struct enum_value { constexpr static std::array value = {10}; }; -} // namespace iguana +} // namespace iguana struct enum_exception_t { State a; @@ -641,7 +644,7 @@ class some_object { int id; std::string name; -public: + public: some_object() = default; some_object(int i, std::string str) : id(i), name(str) {} int get_id() const { return id; }