From 2b132bc33afcace21e088d7ce1f6ddfc9bab0efe Mon Sep 17 00:00:00 2001 From: ado Date: Sat, 5 Aug 2023 12:05:17 +0200 Subject: [PATCH] Apply minor changes to tests --- include/ss/extract.hpp | 1 + include/ss/parser.hpp | 6 +++--- include/ss/splitter.hpp | 2 -- test/test_extractions.cpp | 8 ++++---- test/test_parser.cpp | 7 +++++++ 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/include/ss/extract.hpp b/include/ss/extract.hpp index e84e3e2..f630477 100644 --- a/include/ss/extract.hpp +++ b/include/ss/extract.hpp @@ -16,6 +16,7 @@ #include #endif +// TODO try from_chars for integer conversions namespace ss { //////////////// diff --git a/include/ss/parser.hpp b/include/ss/parser.hpp index f894d0f..3d59e0a 100644 --- a/include/ss/parser.hpp +++ b/include/ss/parser.hpp @@ -574,7 +574,6 @@ private: : delim_{delim}, file_{fopen(file_name_.c_str(), "rb")} { } - // TODO test for next_line_size_ reader(reader&& other) : buffer_{other.buffer_}, next_line_buffer_{other.next_line_buffer_}, @@ -771,12 +770,13 @@ private: const char* const second, size_t second_size) { // TODO make buffer_size an argument next_line_buffer_size_ = first_size + second_size + 3; - first = static_cast( + auto new_first = static_cast( realloc(static_cast(first), next_line_buffer_size_)); if (!first) { - // TODO restore first in order to prevent memory leak throw std::bad_alloc{}; } + + first = new_first; std::copy_n(second, second_size + 1, first + first_size); first_size += second_size; } diff --git a/include/ss/splitter.hpp b/include/ss/splitter.hpp index b0f6d87..dfb44c1 100644 --- a/include/ss/splitter.hpp +++ b/include/ss/splitter.hpp @@ -25,7 +25,6 @@ private: constexpr static auto throw_on_error = setup::throw_on_error; constexpr static auto is_const_line = !quote::enabled && !escape::enabled; - // TODO make error_type none if throw_on_error using error_type = std::conditional_t; public: @@ -149,7 +148,6 @@ private: } } - // TODO rename with handle error void handle_error_unterminated_escape() { constexpr static auto error_msg = "unterminated escape at the end of the line"; diff --git a/test/test_extractions.cpp b/test/test_extractions.cpp index bda33b4..b8dd858 100644 --- a/test/test_extractions.cpp +++ b/test/test_extractions.cpp @@ -6,11 +6,11 @@ TEST_CASE("testing extract functions for floating point values") { CHECK_FLOATING_CONVERSION(123.456, float); CHECK_FLOATING_CONVERSION(123.456, double); - CHECK_FLOATING_CONVERSION(69, float); - CHECK_FLOATING_CONVERSION(69, double); + CHECK_FLOATING_CONVERSION(59, float); + CHECK_FLOATING_CONVERSION(59, double); - CHECK_FLOATING_CONVERSION(420., float); - CHECK_FLOATING_CONVERSION(420., double); + CHECK_FLOATING_CONVERSION(4210., float); + CHECK_FLOATING_CONVERSION(4210., double); CHECK_FLOATING_CONVERSION(0.123, float); CHECK_FLOATING_CONVERSION(0.123, double); diff --git a/test/test_parser.cpp b/test/test_parser.cpp index 393e624..5b4dfa7 100644 --- a/test/test_parser.cpp +++ b/test/test_parser.cpp @@ -125,7 +125,14 @@ void test_various_cases() { ss::parser p2{f.name, ","}; std::vector i2; + auto move_rotate = [&] { + auto p1 = std::move(p); + p0 = std::move(p1); + p = std::move(p0); + }; + while (!p.eof()) { + move_rotate(); auto a = p.template get_next(); i.emplace_back(ss::to_object(a)); }