[skip ci] Fix line method

This commit is contained in:
ado 2024-02-25 02:57:46 +01:00
parent 88e711a5f7
commit 05f87bc78b
3 changed files with 10 additions and 12 deletions

View File

@ -102,7 +102,7 @@ public:
}
size_t line() const {
return reader_.line_number_ > 1 ? reader_.line_number_ - 1
return reader_.line_number_ > 0 ? reader_.line_number_ - 1
: reader_.line_number_;
}
@ -697,8 +697,7 @@ private:
csv_data_buffer_{other.csv_data_buffer_},
csv_data_size_{other.csv_data_size_},
curr_char_{other.curr_char_}, crlf_{other.crlf_},
line_number_{other.line_number_},
chars_read_{other.chars_read_},
line_number_{other.line_number_}, chars_read_{other.chars_read_},
next_line_size_{other.next_line_size_} {
other.buffer_ = nullptr;
other.next_line_buffer_ = nullptr;

View File

@ -78,8 +78,8 @@ struct unique_file_name {
unique_file_name(const std::string& test) {
do {
name = "random_" + test + "_" + std::to_string(i++) + "_" +
time_now_rand() + "_file.csv";
name = "random_file_test_" + test + "_" + std::to_string(i++) +
"_" + time_now_rand() + "_file.csv";
} while (std::filesystem::exists(name));
}

View File

@ -99,17 +99,17 @@ TEST_CASE_TEMPLATE("test position method", T, ParserOptionCombinations) {
}
}
// TODO uncomment
/*
TEST_CASE_TEMPLATE("test line method", BufferMode, std::true_type,
std::false_type) {
unique_file_name f{"test_parser"};
TEST_CASE_TEMPLATE("test line method", T, ParserOptionCombinations) {
constexpr auto buffer_mode = T::BufferMode::value;
using ErrorMode = typename T::ErrorMode;
unique_file_name f{"line_method"};
std::vector<Y> data = {{"1", "21", "x"}, {"321", "4", "y"},
{"54", "6", "zz"}, {"7", "876", "uuuu"},
{"910", "10", "v"}, {"10", "321", "ww"}};
make_and_write(f.name, data);
auto [p, buff] = make_parser<BufferMode::value>(f.name);
auto [p, buff] = make_parser<buffer_mode, ErrorMode>(f.name);
auto expected_line = 0;
CHECK_EQ(p.line(), expected_line);
@ -122,7 +122,6 @@ TEST_CASE_TEMPLATE("test line method", BufferMode, std::true_type,
CHECK_EQ(p.line(), data.size());
}
*/
TEST_CASE_TEMPLATE("parser test various valid cases", T,
ParserOptionCombinations) {