mirror of
https://github.com/red0124/ssp.git
synced 2025-02-02 16:51:12 +01:00
Make throw_on_error and string_error separate options, update parser to have line reading a separate function with respect to splitting
This commit is contained in:
parent
41b89d1d3d
commit
a7a97b3ba8
@ -236,8 +236,7 @@ private:
|
|||||||
if constexpr (string_error) {
|
if constexpr (string_error) {
|
||||||
error_.clear();
|
error_.clear();
|
||||||
error_.append(splitter_.error_msg());
|
error_.append(splitter_.error_msg());
|
||||||
throw_if_throw_on_error<throw_on_error>(error_);
|
} else if constexpr (!throw_on_error) {
|
||||||
} else {
|
|
||||||
error_ = true;
|
error_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -247,28 +246,46 @@ private:
|
|||||||
error_.clear();
|
error_.clear();
|
||||||
splitter_.set_error_unterminated_escape();
|
splitter_.set_error_unterminated_escape();
|
||||||
error_.append(splitter_.error_msg());
|
error_.append(splitter_.error_msg());
|
||||||
throw_if_throw_on_error<throw_on_error>(error_);
|
} else if constexpr (throw_on_error) {
|
||||||
|
splitter_.set_error_unterminated_escape();
|
||||||
|
} else {
|
||||||
|
error_ = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_error_unterminated_quote() {
|
||||||
|
if constexpr (string_error) {
|
||||||
|
error_.clear();
|
||||||
|
splitter_.set_error_unterminated_quote();
|
||||||
|
error_.append(splitter_.error_msg());
|
||||||
|
} else if constexpr (throw_on_error) {
|
||||||
|
splitter_.set_error_unterminated_quote();
|
||||||
} else {
|
} else {
|
||||||
error_ = true;
|
error_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_error_multiline_limit_reached() {
|
void set_error_multiline_limit_reached() {
|
||||||
|
constexpr static auto error_msg = "multiline limit reached";
|
||||||
|
|
||||||
if constexpr (string_error) {
|
if constexpr (string_error) {
|
||||||
error_.clear();
|
error_.clear();
|
||||||
error_.append("multiline limit reached");
|
error_.append(error_msg);
|
||||||
throw_if_throw_on_error<throw_on_error>(error_);
|
} else if constexpr (throw_on_error) {
|
||||||
|
throw ss::exception{error_msg};
|
||||||
} else {
|
} else {
|
||||||
error_ = true;
|
error_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_error_invalid_conversion(const string_range msg, size_t pos) {
|
void set_error_invalid_conversion(const string_range msg, size_t pos) {
|
||||||
|
constexpr static auto error_msg = "invalid conversion for parameter ";
|
||||||
|
|
||||||
if constexpr (string_error) {
|
if constexpr (string_error) {
|
||||||
error_.clear();
|
error_.clear();
|
||||||
error_.append("invalid conversion for parameter ")
|
error_.append(error_msg).append(error_sufix(msg, pos));
|
||||||
.append(error_sufix(msg, pos));
|
} else if constexpr (throw_on_error) {
|
||||||
throw_if_throw_on_error<throw_on_error>(error_);
|
throw ss::exception{error_msg + error_sufix(msg, pos)};
|
||||||
} else {
|
} else {
|
||||||
error_ = true;
|
error_ = true;
|
||||||
}
|
}
|
||||||
@ -279,20 +296,27 @@ private:
|
|||||||
if constexpr (string_error) {
|
if constexpr (string_error) {
|
||||||
error_.clear();
|
error_.clear();
|
||||||
error_.append(error).append(" ").append(error_sufix(msg, pos));
|
error_.append(error).append(" ").append(error_sufix(msg, pos));
|
||||||
throw_if_throw_on_error<throw_on_error>(error_);
|
} else if constexpr (throw_on_error) {
|
||||||
|
throw ss::exception{error + (" " + error_sufix(msg, pos))};
|
||||||
} else {
|
} else {
|
||||||
error_ = true;
|
error_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_error_number_of_columns(size_t expected_pos, size_t pos) {
|
void set_error_number_of_columns(size_t expected_pos, size_t pos) {
|
||||||
|
constexpr static auto error_msg1 =
|
||||||
|
"invalid number of columns, expected: ";
|
||||||
|
constexpr static auto error_msg2 = ", got: ";
|
||||||
|
|
||||||
if constexpr (string_error) {
|
if constexpr (string_error) {
|
||||||
error_.clear();
|
error_.clear();
|
||||||
error_.append("invalid number of columns, expected: ")
|
error_.append(error_msg1)
|
||||||
.append(std::to_string(expected_pos))
|
.append(std::to_string(expected_pos))
|
||||||
.append(", got: ")
|
.append(error_msg2)
|
||||||
.append(std::to_string(pos));
|
.append(std::to_string(pos));
|
||||||
throw_if_throw_on_error<throw_on_error>(error_);
|
} else if constexpr (throw_on_error) {
|
||||||
|
throw ss::exception{error_msg1 + std::to_string(expected_pos) +
|
||||||
|
error_msg2 + std::to_string(pos)};
|
||||||
} else {
|
} else {
|
||||||
error_ = true;
|
error_ = true;
|
||||||
}
|
}
|
||||||
@ -300,25 +324,32 @@ private:
|
|||||||
|
|
||||||
void set_error_incompatible_mapping(size_t argument_size,
|
void set_error_incompatible_mapping(size_t argument_size,
|
||||||
size_t mapping_size) {
|
size_t mapping_size) {
|
||||||
|
constexpr static auto error_msg1 =
|
||||||
|
"number of arguments does not match mapping, expected: ";
|
||||||
|
constexpr static auto error_msg2 = ", got: ";
|
||||||
|
|
||||||
if constexpr (string_error) {
|
if constexpr (string_error) {
|
||||||
error_.clear();
|
error_.clear();
|
||||||
error_
|
error_.append(error_msg1)
|
||||||
.append(
|
|
||||||
"number of arguments does not match mapping, expected: ")
|
|
||||||
.append(std::to_string(mapping_size))
|
.append(std::to_string(mapping_size))
|
||||||
.append(", got: ")
|
.append(error_msg2)
|
||||||
.append(std::to_string(argument_size));
|
.append(std::to_string(argument_size));
|
||||||
throw_if_throw_on_error<throw_on_error>(error_);
|
} else if constexpr (throw_on_error) {
|
||||||
|
throw ss::exception{error_msg1 + std::to_string(mapping_size) +
|
||||||
|
error_msg2 + std::to_string(argument_size)};
|
||||||
} else {
|
} else {
|
||||||
error_ = true;
|
error_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_error_invalid_mapping() {
|
void set_error_invalid_mapping() {
|
||||||
|
constexpr static auto error_msg = "received empty mapping";
|
||||||
|
|
||||||
if constexpr (string_error) {
|
if constexpr (string_error) {
|
||||||
error_.clear();
|
error_.clear();
|
||||||
error_.append("received empty mapping");
|
error_.append(error_msg);
|
||||||
throw_if_throw_on_error<throw_on_error>(error_);
|
} else if constexpr (throw_on_error) {
|
||||||
|
throw ss::exception{error_msg};
|
||||||
} else {
|
} else {
|
||||||
error_ = true;
|
error_ = true;
|
||||||
}
|
}
|
||||||
@ -326,13 +357,19 @@ private:
|
|||||||
|
|
||||||
void set_error_mapping_out_of_range(size_t maximum_index,
|
void set_error_mapping_out_of_range(size_t maximum_index,
|
||||||
size_t number_of_columnts) {
|
size_t number_of_columnts) {
|
||||||
|
constexpr static auto error_msg1 = "maximum index: ";
|
||||||
|
constexpr static auto error_msg2 = ", greater than number of columns: ";
|
||||||
|
|
||||||
if constexpr (string_error) {
|
if constexpr (string_error) {
|
||||||
error_.clear();
|
error_.clear();
|
||||||
error_.append("maximum index: ")
|
error_.append(error_msg1)
|
||||||
.append(std::to_string(maximum_index))
|
.append(std::to_string(maximum_index))
|
||||||
.append(", greater then number of columns: ")
|
.append(error_msg2)
|
||||||
.append(std::to_string(number_of_columnts));
|
.append(std::to_string(number_of_columnts));
|
||||||
throw_if_throw_on_error<throw_on_error>(error_);
|
} else if constexpr (throw_on_error) {
|
||||||
|
throw ss::exception{error_msg1 + std::to_string(maximum_index) +
|
||||||
|
error_msg2 +
|
||||||
|
std::to_string(number_of_columnts)};
|
||||||
} else {
|
} else {
|
||||||
error_ = true;
|
error_ = true;
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,4 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <bool throw_on_error>
|
|
||||||
void throw_if_throw_on_error(const std::string& msg) {
|
|
||||||
if constexpr (throw_on_error) {
|
|
||||||
throw ss::exception(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} /* ss */
|
} /* ss */
|
||||||
|
@ -87,8 +87,19 @@ public:
|
|||||||
|
|
||||||
template <typename T, typename... Ts>
|
template <typename T, typename... Ts>
|
||||||
no_void_validator_tup_t<T, Ts...> get_next() {
|
no_void_validator_tup_t<T, Ts...> get_next() {
|
||||||
|
if (!eof_) {
|
||||||
|
reader_.parse();
|
||||||
|
}
|
||||||
|
|
||||||
reader_.update();
|
reader_.update();
|
||||||
|
if (!reader_.converter_.valid()) {
|
||||||
|
set_error_invalid_conversion();
|
||||||
|
read_line();
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
clear_error();
|
clear_error();
|
||||||
|
|
||||||
if (eof_) {
|
if (eof_) {
|
||||||
set_error_eof_reached();
|
set_error_eof_reached();
|
||||||
return {};
|
return {};
|
||||||
@ -424,27 +435,36 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void set_error_failed_check() {
|
void set_error_failed_check() {
|
||||||
|
constexpr static auto error_msg = " failed check";
|
||||||
|
|
||||||
if constexpr (string_error) {
|
if constexpr (string_error) {
|
||||||
error_.append(file_name_).append(" failed check");
|
error_.append(file_name_).append(error_msg);
|
||||||
throw_if_throw_on_error<throw_on_error>(error_);
|
} else if constexpr (throw_on_error) {
|
||||||
|
throw ss::exception{file_name_ + error_msg};
|
||||||
} else {
|
} else {
|
||||||
error_ = true;
|
error_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_error_file_not_open() {
|
void set_error_file_not_open() {
|
||||||
|
constexpr static auto error_msg = " could not be opened";
|
||||||
|
|
||||||
if constexpr (string_error) {
|
if constexpr (string_error) {
|
||||||
error_.append(file_name_).append(" could not be opened");
|
error_.append(file_name_).append(" could not be opened");
|
||||||
throw_if_throw_on_error<throw_on_error>(error_);
|
} else if constexpr (throw_on_error) {
|
||||||
|
throw ss::exception{file_name_ + error_msg};
|
||||||
} else {
|
} else {
|
||||||
error_ = true;
|
error_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_error_eof_reached() {
|
void set_error_eof_reached() {
|
||||||
|
constexpr static auto error_msg = " reached end of file";
|
||||||
|
|
||||||
if constexpr (string_error) {
|
if constexpr (string_error) {
|
||||||
error_.append(file_name_).append(" reached end of file");
|
error_.append(file_name_).append(" reached end of file");
|
||||||
throw_if_throw_on_error<throw_on_error>(error_);
|
} else if constexpr (throw_on_error) {
|
||||||
|
throw ss::exception{file_name_ + error_msg};
|
||||||
} else {
|
} else {
|
||||||
error_ = true;
|
error_ = true;
|
||||||
}
|
}
|
||||||
@ -460,42 +480,45 @@ private:
|
|||||||
.append(": \"")
|
.append(": \"")
|
||||||
.append(reader_.buffer_)
|
.append(reader_.buffer_)
|
||||||
.append("\"");
|
.append("\"");
|
||||||
throw_if_throw_on_error<throw_on_error>(error_);
|
} else if constexpr (!throw_on_error) {
|
||||||
} else {
|
|
||||||
error_ = true;
|
error_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_error_header_ignored() {
|
void set_error_header_ignored() {
|
||||||
|
constexpr static auto error_msg =
|
||||||
|
": \"the header row is ignored within the setup it cannot be "
|
||||||
|
"used\"";
|
||||||
|
|
||||||
if constexpr (string_error) {
|
if constexpr (string_error) {
|
||||||
error_.append(file_name_)
|
error_.append(file_name_).append(error_msg);
|
||||||
.append(": \"")
|
} else if constexpr (throw_on_error) {
|
||||||
.append("the header row is ignored within the setup, it cannot "
|
throw ss::exception{file_name_ + error_msg};
|
||||||
"be used")
|
|
||||||
.append("\"");
|
|
||||||
throw_if_throw_on_error<throw_on_error>(error_);
|
|
||||||
} else {
|
} else {
|
||||||
error_ = true;
|
error_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_error_invalid_field(const std::string& field) {
|
void set_error_invalid_field(const std::string& field) {
|
||||||
|
constexpr static auto error_msg =
|
||||||
|
": header does not contain given field: ";
|
||||||
|
|
||||||
if constexpr (string_error) {
|
if constexpr (string_error) {
|
||||||
error_.append(file_name_)
|
error_.append(file_name_).append(error_msg).append(field);
|
||||||
.append(": header does not contain given field: ")
|
} else if constexpr (throw_on_error) {
|
||||||
.append(field);
|
throw ss::exception{file_name_ + error_msg + field};
|
||||||
throw_if_throw_on_error<throw_on_error>(error_);
|
|
||||||
} else {
|
} else {
|
||||||
error_ = true;
|
error_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_error_field_used_multiple_times(const std::string& field) {
|
void set_error_field_used_multiple_times(const std::string& field) {
|
||||||
|
constexpr static auto error_msg = ": given field used multiple times: ";
|
||||||
|
|
||||||
if constexpr (string_error) {
|
if constexpr (string_error) {
|
||||||
error_.append(file_name_)
|
error_.append(file_name_).append(error_msg).append(field);
|
||||||
.append(": given field used multiple times: ")
|
} else if constexpr (throw_on_error) {
|
||||||
.append(field);
|
throw ss::exception{file_name_ + error_msg + field};
|
||||||
throw_if_throw_on_error<throw_on_error>(error_);
|
|
||||||
} else {
|
} else {
|
||||||
error_ = true;
|
error_ = true;
|
||||||
}
|
}
|
||||||
@ -514,13 +537,15 @@ private:
|
|||||||
: delim_{delim}, file_{fopen(file_name_.c_str(), "rb")} {
|
: delim_{delim}, file_{fopen(file_name_.c_str(), "rb")} {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO update for size_ and ssize_
|
||||||
reader(reader&& other)
|
reader(reader&& other)
|
||||||
: buffer_{other.buffer_},
|
: buffer_{other.buffer_},
|
||||||
next_line_buffer_{other.next_line_buffer_},
|
next_line_buffer_{other.next_line_buffer_},
|
||||||
helper_buffer_{other.helper_buffer_}, converter_{std::move(
|
helper_buffer_{other.helper_buffer_}, converter_{std::move(
|
||||||
other.converter_)},
|
other.converter_)},
|
||||||
next_line_converter_{std::move(other.next_line_converter_)},
|
next_line_converter_{std::move(other.next_line_converter_)},
|
||||||
size_{other.size_}, next_line_size_{other.next_line_size_},
|
buffer_size_{other.size_},
|
||||||
|
next_line_buffer_size_{other.next_line_buffer_size_},
|
||||||
helper_size_{other.helper_size_}, delim_{std::move(other.delim_)},
|
helper_size_{other.helper_size_}, delim_{std::move(other.delim_)},
|
||||||
file_{other.file_}, crlf_{other.crlf_}, line_number_{
|
file_{other.file_}, crlf_{other.crlf_}, line_number_{
|
||||||
other.line_number_} {
|
other.line_number_} {
|
||||||
@ -537,8 +562,8 @@ private:
|
|||||||
helper_buffer_ = other.helper_buffer_;
|
helper_buffer_ = other.helper_buffer_;
|
||||||
converter_ = std::move(other.converter_);
|
converter_ = std::move(other.converter_);
|
||||||
next_line_converter_ = std::move(other.next_line_converter_);
|
next_line_converter_ = std::move(other.next_line_converter_);
|
||||||
size_ = other.size_;
|
buffer_size_ = other.size_;
|
||||||
next_line_size_ = other.next_line_size_;
|
next_line_buffer_size_ = other.next_line_buffer_size_;
|
||||||
helper_size_ = other.helper_size_;
|
helper_size_ = other.helper_size_;
|
||||||
delim_ = std::move(other.delim_);
|
delim_ = std::move(other.delim_);
|
||||||
file_ = other.file_;
|
file_ = other.file_;
|
||||||
@ -568,16 +593,18 @@ private:
|
|||||||
reader(const reader& other) = delete;
|
reader(const reader& other) = delete;
|
||||||
reader& operator=(const reader& other) = delete;
|
reader& operator=(const reader& other) = delete;
|
||||||
|
|
||||||
|
// read next line each time in order to set eof_
|
||||||
bool read_next() {
|
bool read_next() {
|
||||||
|
next_line_converter_.clear_error();
|
||||||
ssize_t ssize;
|
ssize_t ssize = 0;
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
while (size == 0) {
|
while (size == 0) {
|
||||||
++line_number_;
|
++line_number_;
|
||||||
if (next_line_size_ > 0) {
|
if (next_line_buffer_size_ > 0) {
|
||||||
next_line_buffer_[0] = '\0';
|
next_line_buffer_[0] = '\0';
|
||||||
}
|
}
|
||||||
ssize = get_line(&next_line_buffer_, &next_line_size_, file_);
|
ssize = get_line(&next_line_buffer_, &next_line_buffer_size_,
|
||||||
|
file_);
|
||||||
|
|
||||||
if (ssize == -1) {
|
if (ssize == -1) {
|
||||||
return false;
|
return false;
|
||||||
@ -590,17 +617,24 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_ = size;
|
||||||
|
ssize_ = ssize;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void parse() {
|
||||||
size_t limit = 0;
|
size_t limit = 0;
|
||||||
|
|
||||||
if constexpr (escaped_multiline_enabled) {
|
if constexpr (escaped_multiline_enabled) {
|
||||||
while (escaped_eol(size)) {
|
while (escaped_eol(size_)) {
|
||||||
if (multiline_limit_reached(limit)) {
|
if (multiline_limit_reached(limit)) {
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
if (!append_next_line_to_buffer(next_line_buffer_, size)) {
|
|
||||||
remove_eol(next_line_buffer_, ssize);
|
if (!append_next_line_to_buffer(next_line_buffer_, size_)) {
|
||||||
|
// remove_eol(next_line_buffer_, ssize_);
|
||||||
next_line_converter_.set_error_unterminated_escape();
|
next_line_converter_.set_error_unterminated_escape();
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -610,38 +644,40 @@ private:
|
|||||||
if constexpr (quoted_multiline_enabled) {
|
if constexpr (quoted_multiline_enabled) {
|
||||||
while (unterminated_quote()) {
|
while (unterminated_quote()) {
|
||||||
if (multiline_limit_reached(limit)) {
|
if (multiline_limit_reached(limit)) {
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
if (!append_next_line_to_buffer(next_line_buffer_, size)) {
|
|
||||||
remove_eol(next_line_buffer_, ssize);
|
if (!append_next_line_to_buffer(next_line_buffer_, size_)) {
|
||||||
return true;
|
// remove_eol(next_line_buffer_, ssize_);
|
||||||
|
next_line_converter_.set_error_unterminated_quote();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if constexpr (escaped_multiline_enabled) {
|
if constexpr (escaped_multiline_enabled) {
|
||||||
while (escaped_eol(size)) {
|
while (escaped_eol(size_)) {
|
||||||
if (multiline_limit_reached(limit)) {
|
if (multiline_limit_reached(limit)) {
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!append_next_line_to_buffer(next_line_buffer_,
|
if (!append_next_line_to_buffer(next_line_buffer_,
|
||||||
size)) {
|
size_)) {
|
||||||
remove_eol(next_line_buffer_, ssize);
|
// TODO not needed
|
||||||
|
// remove_eol(next_line_buffer_, ssize_);
|
||||||
next_line_converter_
|
next_line_converter_
|
||||||
.set_error_unterminated_escape();
|
.set_error_unterminated_escape();
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
next_line_converter_.resplit(next_line_buffer_, size);
|
next_line_converter_.resplit(next_line_buffer_, size_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void update() {
|
void update() {
|
||||||
std::swap(buffer_, next_line_buffer_);
|
std::swap(buffer_, next_line_buffer_);
|
||||||
std::swap(size_, next_line_size_);
|
std::swap(buffer_size_, next_line_buffer_size_);
|
||||||
std::swap(converter_, next_line_converter_);
|
std::swap(converter_, next_line_converter_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -666,10 +702,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool unterminated_quote() {
|
bool unterminated_quote() {
|
||||||
if (next_line_converter_.unterminated_quote()) {
|
return next_line_converter_.unterminated_quote();
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void undo_remove_eol(char* buffer, size_t& string_end) {
|
void undo_remove_eol(char* buffer, size_t& string_end) {
|
||||||
@ -685,24 +718,29 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t remove_eol(char*& buffer, size_t size) {
|
size_t remove_eol(char*& buffer, size_t ssize) {
|
||||||
size_t new_size = size - 1;
|
size_t size = ssize - 1;
|
||||||
if (size >= 2 && buffer[size - 2] == '\r') {
|
if (ssize >= 2 && buffer[ssize - 2] == '\r') {
|
||||||
crlf_ = true;
|
crlf_ = true;
|
||||||
new_size--;
|
size--;
|
||||||
} else {
|
} else {
|
||||||
crlf_ = false;
|
crlf_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer[new_size] = '\0';
|
buffer[size] = '\0';
|
||||||
return new_size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void realloc_concat(char*& first, size_t& first_size,
|
void realloc_concat(char*& first, size_t& first_size,
|
||||||
const char* const second, size_t second_size) {
|
const char* const second, size_t second_size) {
|
||||||
next_line_size_ = first_size + second_size + 3;
|
// TODO make buffer_size an argument !!!!!!
|
||||||
|
next_line_buffer_size_ = first_size + second_size + 3;
|
||||||
first = static_cast<char*>(
|
first = static_cast<char*>(
|
||||||
realloc(static_cast<void*>(first), next_line_size_));
|
realloc(static_cast<void*>(first), next_line_buffer_size_));
|
||||||
|
// TODO handle realloc
|
||||||
|
if (!first) {
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
std::copy_n(second, second_size + 1, first + first_size);
|
std::copy_n(second, second_size + 1, first + first_size);
|
||||||
first_size += second_size;
|
first_size += second_size;
|
||||||
}
|
}
|
||||||
@ -722,8 +760,9 @@ private:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> get_next_row() const {
|
std::vector<std::string> get_next_row() {
|
||||||
std::vector<std::string> next_row;
|
std::vector<std::string> next_row;
|
||||||
|
next_line_converter_.split(next_line_buffer_, delim_);
|
||||||
auto& next_row_raw = next_line_converter_.splitter_.split_data_;
|
auto& next_row_raw = next_line_converter_.splitter_.split_data_;
|
||||||
for (const auto& [begin, end] : next_row_raw) {
|
for (const auto& [begin, end] : next_row_raw) {
|
||||||
next_row.emplace_back(begin, end);
|
next_row.emplace_back(begin, end);
|
||||||
@ -741,8 +780,8 @@ private:
|
|||||||
converter<Options...> converter_;
|
converter<Options...> converter_;
|
||||||
converter<Options...> next_line_converter_;
|
converter<Options...> next_line_converter_;
|
||||||
|
|
||||||
size_t size_{0};
|
size_t buffer_size_{0};
|
||||||
size_t next_line_size_{0};
|
size_t next_line_buffer_size_{0};
|
||||||
size_t helper_size_{0};
|
size_t helper_size_{0};
|
||||||
|
|
||||||
std::string delim_;
|
std::string delim_;
|
||||||
@ -750,6 +789,10 @@ private:
|
|||||||
|
|
||||||
bool crlf_;
|
bool crlf_;
|
||||||
size_t line_number_{0};
|
size_t line_number_{0};
|
||||||
|
|
||||||
|
// TODO check if needed
|
||||||
|
size_t size_{0};
|
||||||
|
ssize_t ssize_{0};
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////
|
////////////////
|
||||||
|
@ -112,7 +112,7 @@ struct get_matcher<Matcher, T, Ts...> {
|
|||||||
"the same matcher is cannot"
|
"the same matcher is cannot"
|
||||||
"be defined multiple times");
|
"be defined multiple times");
|
||||||
using type = std::conditional_t<is_matcher<T>::value, T,
|
using type = std::conditional_t<is_matcher<T>::value, T,
|
||||||
typename get_matcher<Matcher, Ts...>::type>;
|
typename get_matcher<Matcher, Ts...>::type>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <template <char...> class Matcher>
|
template <template <char...> class Matcher>
|
||||||
@ -150,7 +150,7 @@ struct get_multiline;
|
|||||||
template <typename T, typename... Ts>
|
template <typename T, typename... Ts>
|
||||||
struct get_multiline<T, Ts...> {
|
struct get_multiline<T, Ts...> {
|
||||||
using type = std::conditional_t<is_instance_of_multiline<T>::value, T,
|
using type = std::conditional_t<is_instance_of_multiline<T>::value, T,
|
||||||
typename get_multiline<Ts...>::type>;
|
typename get_multiline<Ts...>::type>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
@ -217,7 +217,8 @@ private:
|
|||||||
constexpr static auto count_multiline =
|
constexpr static auto count_multiline =
|
||||||
count_v<is_instance_of_multiline, Options...>;
|
count_v<is_instance_of_multiline, Options...>;
|
||||||
|
|
||||||
constexpr static auto count_string_error = count_v<is_string_error, Options...>;
|
constexpr static auto count_string_error =
|
||||||
|
count_v<is_string_error, Options...>;
|
||||||
|
|
||||||
constexpr static auto count_ignore_header =
|
constexpr static auto count_ignore_header =
|
||||||
count_v<is_ignore_header, Options...>;
|
count_v<is_ignore_header, Options...>;
|
||||||
@ -225,7 +226,8 @@ private:
|
|||||||
constexpr static auto count_throw_on_error =
|
constexpr static auto count_throw_on_error =
|
||||||
count_v<is_throw_on_error, Options...>;
|
count_v<is_throw_on_error, Options...>;
|
||||||
|
|
||||||
constexpr static auto count_ignore_empty = count_v<is_ignore_empty, Options...>;
|
constexpr static auto count_ignore_empty =
|
||||||
|
count_v<is_ignore_empty, Options...>;
|
||||||
|
|
||||||
constexpr static auto number_of_valid_setup_types =
|
constexpr static auto number_of_valid_setup_types =
|
||||||
count_matcher + count_multiline + count_string_error +
|
count_matcher + count_multiline + count_string_error +
|
||||||
@ -249,8 +251,6 @@ public:
|
|||||||
constexpr static bool ignore_header = (count_ignore_header == 1);
|
constexpr static bool ignore_header = (count_ignore_header == 1);
|
||||||
constexpr static bool ignore_empty = (count_ignore_empty == 1);
|
constexpr static bool ignore_empty = (count_ignore_empty == 1);
|
||||||
constexpr static bool throw_on_error = (count_throw_on_error == 1);
|
constexpr static bool throw_on_error = (count_throw_on_error == 1);
|
||||||
// TODO set string_error if throw_on_error is defined
|
|
||||||
// TODO throw_on_error should be unique
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#define ASSERT_MSG "cannot have the same match character in multiple matchers"
|
#define ASSERT_MSG "cannot have the same match character in multiple matchers"
|
||||||
@ -276,9 +276,16 @@ private:
|
|||||||
"ambiguous trim setup");
|
"ambiguous trim setup");
|
||||||
|
|
||||||
static_assert(count_multiline <= 1, "mutliline defined multiple times");
|
static_assert(count_multiline <= 1, "mutliline defined multiple times");
|
||||||
|
|
||||||
static_assert(count_string_error <= 1,
|
static_assert(count_string_error <= 1,
|
||||||
"string_error defined multiple times");
|
"string_error defined multiple times");
|
||||||
|
|
||||||
|
static_assert(count_throw_on_error <= 1,
|
||||||
|
"throw_on_error defined multiple times");
|
||||||
|
|
||||||
|
static_assert(count_throw_on_error + count_string_error <= 1,
|
||||||
|
"cannot define both throw_on_error and string_error");
|
||||||
|
|
||||||
static_assert(number_of_valid_setup_types == sizeof...(Options),
|
static_assert(number_of_valid_setup_types == sizeof...(Options),
|
||||||
"one or multiple invalid setup parameters defined");
|
"one or multiple invalid setup parameters defined");
|
||||||
};
|
};
|
||||||
|
@ -25,6 +25,7 @@ private:
|
|||||||
constexpr static auto throw_on_error = setup<Options...>::throw_on_error;
|
constexpr static auto throw_on_error = setup<Options...>::throw_on_error;
|
||||||
constexpr static auto is_const_line = !quote::enabled && !escape::enabled;
|
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<string_error, std::string, bool>;
|
using error_type = std::conditional_t<string_error, std::string, bool>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -77,10 +78,11 @@ private:
|
|||||||
const std::string& delimiter = default_delimiter) {
|
const std::string& delimiter = default_delimiter) {
|
||||||
|
|
||||||
// resplitting, continue from last slice
|
// resplitting, continue from last slice
|
||||||
if (!quote::enabled || !multiline::enabled || split_data_.empty() ||
|
if constexpr (!quote::enabled || !multiline::enabled) {
|
||||||
!unterminated_quote()) {
|
if (split_data_.empty() || !unterminated_quote()) {
|
||||||
set_error_invalid_resplit();
|
set_error_invalid_resplit();
|
||||||
return split_data_;
|
return split_data_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto [old_line, old_begin] = *std::prev(split_data_.end());
|
const auto [old_line, old_begin] = *std::prev(split_data_.end());
|
||||||
@ -88,6 +90,7 @@ private:
|
|||||||
|
|
||||||
// safety measure
|
// safety measure
|
||||||
if (new_size != -1 && static_cast<size_t>(new_size) < begin) {
|
if (new_size != -1 && static_cast<size_t>(new_size) < begin) {
|
||||||
|
unterminated_quote_ = false;
|
||||||
set_error_invalid_resplit();
|
set_error_invalid_resplit();
|
||||||
return split_data_;
|
return split_data_;
|
||||||
}
|
}
|
||||||
@ -114,62 +117,77 @@ private:
|
|||||||
void clear_error() {
|
void clear_error() {
|
||||||
if constexpr (string_error) {
|
if constexpr (string_error) {
|
||||||
error_.clear();
|
error_.clear();
|
||||||
} else {
|
} else if constexpr (!throw_on_error) {
|
||||||
error_ = false;
|
error_ = false;
|
||||||
}
|
}
|
||||||
unterminated_quote_ = false;
|
unterminated_quote_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_error_empty_delimiter() {
|
void set_error_empty_delimiter() {
|
||||||
|
constexpr static auto error_msg = "empty delimiter";
|
||||||
|
|
||||||
if constexpr (string_error) {
|
if constexpr (string_error) {
|
||||||
error_.clear();
|
error_.clear();
|
||||||
error_.append("empty delimiter");
|
error_.append(error_msg);
|
||||||
throw_if_throw_on_error<throw_on_error>(error_);
|
} else if constexpr (throw_on_error) {
|
||||||
|
throw ss::exception{error_msg};
|
||||||
} else {
|
} else {
|
||||||
error_ = true;
|
error_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_error_mismatched_quote(size_t n) {
|
void set_error_mismatched_quote(size_t n) {
|
||||||
|
constexpr static auto error_msg = "mismatched quote at position: ";
|
||||||
|
|
||||||
if constexpr (string_error) {
|
if constexpr (string_error) {
|
||||||
error_.clear();
|
error_.clear();
|
||||||
error_.append("mismatched quote at position: " + std::to_string(n));
|
error_.append(error_msg + std::to_string(n));
|
||||||
throw_if_throw_on_error<throw_on_error>(error_);
|
} else if constexpr (throw_on_error) {
|
||||||
|
throw ss::exception{error_msg + std::to_string(n)};
|
||||||
} else {
|
} else {
|
||||||
error_ = true;
|
error_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO rename with handle error
|
||||||
void set_error_unterminated_escape() {
|
void set_error_unterminated_escape() {
|
||||||
|
constexpr static auto error_msg =
|
||||||
|
"unterminated escape at the end of the line";
|
||||||
|
|
||||||
if constexpr (string_error) {
|
if constexpr (string_error) {
|
||||||
error_.clear();
|
error_.clear();
|
||||||
error_.append("unterminated escape at the end of the line");
|
error_.append(error_msg);
|
||||||
throw_if_throw_on_error<throw_on_error>(error_);
|
} else if constexpr (throw_on_error) {
|
||||||
|
throw ss::exception{error_msg};
|
||||||
} else {
|
} else {
|
||||||
error_ = true;
|
error_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO handle this efficiently
|
// TODO handle this efficiently (if multiline is enabled)
|
||||||
void set_error_unterminated_quote() {
|
void set_error_unterminated_quote() {
|
||||||
unterminated_quote_ = true;
|
constexpr static auto error_msg = "unterminated quote";
|
||||||
|
|
||||||
if constexpr (string_error) {
|
if constexpr (string_error) {
|
||||||
error_.clear();
|
error_.clear();
|
||||||
error_.append("unterminated quote");
|
error_.append(error_msg);
|
||||||
throw_if_throw_on_error<throw_on_error>(error_);
|
} else if constexpr (throw_on_error) {
|
||||||
|
throw ss::exception{error_msg};
|
||||||
} else {
|
} else {
|
||||||
error_ = true;
|
error_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_error_invalid_resplit() {
|
void set_error_invalid_resplit() {
|
||||||
// TODO check this
|
constexpr static auto error_msg =
|
||||||
unterminated_quote_ = false;
|
"invalid resplit, new line must be longer"
|
||||||
|
"than the end of the last slice";
|
||||||
|
|
||||||
if constexpr (string_error) {
|
if constexpr (string_error) {
|
||||||
error_.clear();
|
error_.clear();
|
||||||
error_.append("invalid resplit, new line must be longer"
|
error_.append(error_msg);
|
||||||
"than the end of the last slice");
|
} else if constexpr (throw_on_error) {
|
||||||
throw_if_throw_on_error<throw_on_error>(error_);
|
throw ss::exception{error_msg};
|
||||||
} else {
|
} else {
|
||||||
error_ = true;
|
error_ = true;
|
||||||
}
|
}
|
||||||
@ -244,7 +262,9 @@ private:
|
|||||||
if constexpr (escape::enabled) {
|
if constexpr (escape::enabled) {
|
||||||
if (escape::match(*curr)) {
|
if (escape::match(*curr)) {
|
||||||
if (curr[1] == '\0') {
|
if (curr[1] == '\0') {
|
||||||
set_error_unterminated_escape();
|
if constexpr (!multiline::enabled) {
|
||||||
|
set_error_unterminated_escape();
|
||||||
|
}
|
||||||
done_ = true;
|
done_ = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -371,7 +391,9 @@ private:
|
|||||||
if (end_[1] == '\0') {
|
if (end_[1] == '\0') {
|
||||||
// eol, unterminated escape
|
// eol, unterminated escape
|
||||||
// eg: ... "hel\\0
|
// eg: ... "hel\\0
|
||||||
set_error_unterminated_escape();
|
if constexpr (!multiline::enabled) {
|
||||||
|
set_error_unterminated_escape();
|
||||||
|
}
|
||||||
done_ = true;
|
done_ = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -388,7 +410,10 @@ private:
|
|||||||
// eg: ..."hell\0 -> quote not terminated
|
// eg: ..."hell\0 -> quote not terminated
|
||||||
if (*end_ == '\0') {
|
if (*end_ == '\0') {
|
||||||
shift_and_set_current();
|
shift_and_set_current();
|
||||||
set_error_unterminated_quote();
|
unterminated_quote_ = true;
|
||||||
|
if constexpr (!multiline::enabled) {
|
||||||
|
set_error_unterminated_quote();
|
||||||
|
}
|
||||||
split_data_.emplace_back(line_, begin_);
|
split_data_.emplace_back(line_, begin_);
|
||||||
done_ = true;
|
done_ = true;
|
||||||
break;
|
break;
|
||||||
|
@ -42,7 +42,7 @@ TEST_CASE("converter test split with exceptions") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ TEST_CASE("converter test valid conversions with exceptions") {
|
|||||||
REQUIRE(c.valid());
|
REQUIRE(c.valid());
|
||||||
CHECK_EQ(tup, 5);
|
CHECK_EQ(tup, 5);
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -156,7 +156,7 @@ TEST_CASE("converter test valid conversions with exceptions") {
|
|||||||
REQUIRE(c.valid());
|
REQUIRE(c.valid());
|
||||||
CHECK_EQ(tup, 5);
|
CHECK_EQ(tup, 5);
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -164,7 +164,7 @@ TEST_CASE("converter test valid conversions with exceptions") {
|
|||||||
REQUIRE(c.valid());
|
REQUIRE(c.valid());
|
||||||
CHECK_EQ(tup, 5);
|
CHECK_EQ(tup, 5);
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -172,7 +172,7 @@ TEST_CASE("converter test valid conversions with exceptions") {
|
|||||||
REQUIRE(c.valid());
|
REQUIRE(c.valid());
|
||||||
CHECK_EQ(tup, 5);
|
CHECK_EQ(tup, 5);
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -180,7 +180,7 @@ TEST_CASE("converter test valid conversions with exceptions") {
|
|||||||
REQUIRE(c.valid());
|
REQUIRE(c.valid());
|
||||||
CHECK_EQ(tup, 5);
|
CHECK_EQ(tup, 5);
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -188,7 +188,7 @@ TEST_CASE("converter test valid conversions with exceptions") {
|
|||||||
REQUIRE(c.valid());
|
REQUIRE(c.valid());
|
||||||
CHECK_EQ(tup, 5);
|
CHECK_EQ(tup, 5);
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -198,7 +198,7 @@ TEST_CASE("converter test valid conversions with exceptions") {
|
|||||||
REQUIRE(tup.has_value());
|
REQUIRE(tup.has_value());
|
||||||
CHECK_EQ(tup, 5);
|
CHECK_EQ(tup, 5);
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -206,7 +206,7 @@ TEST_CASE("converter test valid conversions with exceptions") {
|
|||||||
REQUIRE(c.valid());
|
REQUIRE(c.valid());
|
||||||
CHECK_EQ(tup, std::make_tuple(5, 6.6));
|
CHECK_EQ(tup, std::make_tuple(5, 6.6));
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -214,7 +214,7 @@ TEST_CASE("converter test valid conversions with exceptions") {
|
|||||||
REQUIRE(c.valid());
|
REQUIRE(c.valid());
|
||||||
CHECK_EQ(tup, std::make_tuple(5, 6.6));
|
CHECK_EQ(tup, std::make_tuple(5, 6.6));
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -222,7 +222,7 @@ TEST_CASE("converter test valid conversions with exceptions") {
|
|||||||
REQUIRE(c.valid());
|
REQUIRE(c.valid());
|
||||||
CHECK_EQ(tup, std::make_tuple(5, 6.6));
|
CHECK_EQ(tup, std::make_tuple(5, 6.6));
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -232,7 +232,7 @@ TEST_CASE("converter test valid conversions with exceptions") {
|
|||||||
REQUIRE(std::get<0>(tup).has_value());
|
REQUIRE(std::get<0>(tup).has_value());
|
||||||
CHECK_EQ(tup, std::make_tuple(5, 6.6));
|
CHECK_EQ(tup, std::make_tuple(5, 6.6));
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -242,7 +242,7 @@ TEST_CASE("converter test valid conversions with exceptions") {
|
|||||||
REQUIRE_FALSE(std::get<0>(tup).has_value());
|
REQUIRE_FALSE(std::get<0>(tup).has_value());
|
||||||
CHECK_EQ(tup, std::make_tuple(std::optional<int>{}, 6.6));
|
CHECK_EQ(tup, std::make_tuple(std::optional<int>{}, 6.6));
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -253,7 +253,7 @@ TEST_CASE("converter test valid conversions with exceptions") {
|
|||||||
REQUIRE(std::holds_alternative<int>(std::get<0>(tup)));
|
REQUIRE(std::holds_alternative<int>(std::get<0>(tup)));
|
||||||
CHECK_EQ(tup, std::make_tuple(std::variant<int, double>{5}, 6.6));
|
CHECK_EQ(tup, std::make_tuple(std::variant<int, double>{5}, 6.6));
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -264,7 +264,7 @@ TEST_CASE("converter test valid conversions with exceptions") {
|
|||||||
REQUIRE(std::holds_alternative<double>(std::get<0>(tup)));
|
REQUIRE(std::holds_alternative<double>(std::get<0>(tup)));
|
||||||
CHECK_EQ(tup, std::make_tuple(std::variant<int, double>{5.5}, 6.6));
|
CHECK_EQ(tup, std::make_tuple(std::variant<int, double>{5.5}, 6.6));
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -274,7 +274,7 @@ TEST_CASE("converter test valid conversions with exceptions") {
|
|||||||
CHECK_EQ(tup, std::make_tuple(std::string_view{"s1"}, 6.6,
|
CHECK_EQ(tup, std::make_tuple(std::string_view{"s1"}, 6.6,
|
||||||
std::string_view{"s2"}));
|
std::string_view{"s2"}));
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,8 +316,7 @@ TEST_CASE("converter test invalid conversions") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("converter test invalid conversions with exceptions") {
|
TEST_CASE("converter test invalid conversions with exceptions") {
|
||||||
// TODO remove ss::string_error
|
ss::converter<ss::throw_on_error> c;
|
||||||
ss::converter<ss::string_error, ss::throw_on_error> c;
|
|
||||||
|
|
||||||
REQUIRE_EXCEPTION(c.convert<int>(""));
|
REQUIRE_EXCEPTION(c.convert<int>(""));
|
||||||
REQUIRE_EXCEPTION(c.convert<int>("1", ""));
|
REQUIRE_EXCEPTION(c.convert<int>("1", ""));
|
||||||
@ -366,7 +365,7 @@ TEST_CASE("converter test ss:ax restriction (all except)") {
|
|||||||
|
|
||||||
TEST_CASE("converter test ss:ax restriction (all except) with exceptions") {
|
TEST_CASE("converter test ss:ax restriction (all except) with exceptions") {
|
||||||
// TODO remove ss::string_error
|
// TODO remove ss::string_error
|
||||||
ss::converter<ss::string_error, ss::throw_on_error> c;
|
ss::converter<ss::throw_on_error> c;
|
||||||
|
|
||||||
REQUIRE_EXCEPTION(c.convert<ss::ax<int, 0>>("0"));
|
REQUIRE_EXCEPTION(c.convert<ss::ax<int, 0>>("0"));
|
||||||
REQUIRE_EXCEPTION(c.convert<ss::ax<int, 0, 1, 2>>("1"));
|
REQUIRE_EXCEPTION(c.convert<ss::ax<int, 0, 1, 2>>("1"));
|
||||||
@ -387,7 +386,7 @@ TEST_CASE("converter test ss:ax restriction (all except) with exceptions") {
|
|||||||
CHECK_EQ(tup, std::make_tuple(3, 'c'));
|
CHECK_EQ(tup, std::make_tuple(3, 'c'));
|
||||||
}
|
}
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -427,7 +426,7 @@ TEST_CASE("converter test ss:nx restriction (none except)") {
|
|||||||
|
|
||||||
TEST_CASE("converter test ss:nx restriction (none except) with exceptions") {
|
TEST_CASE("converter test ss:nx restriction (none except) with exceptions") {
|
||||||
// TODO remove ss::string_error
|
// TODO remove ss::string_error
|
||||||
ss::converter<ss::string_error, ss::throw_on_error> c;
|
ss::converter<ss::throw_on_error> c;
|
||||||
|
|
||||||
REQUIRE_EXCEPTION(c.convert<ss::nx<int, 1>>("3"));
|
REQUIRE_EXCEPTION(c.convert<ss::nx<int, 1>>("3"));
|
||||||
REQUIRE_EXCEPTION(c.convert<char, ss::nx<int, 1, 2, 69>>("c,3"));
|
REQUIRE_EXCEPTION(c.convert<char, ss::nx<int, 1, 2, 69>>("c,3"));
|
||||||
@ -455,7 +454,7 @@ TEST_CASE("converter test ss:nx restriction (none except) with exceptions") {
|
|||||||
CHECK_EQ(tup, std::make_tuple(1, 'c'));
|
CHECK_EQ(tup, std::make_tuple(1, 'c'));
|
||||||
}
|
}
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -495,7 +494,7 @@ TEST_CASE("converter test ss:ir restriction (in range)") {
|
|||||||
|
|
||||||
TEST_CASE("converter test ss:ir restriction (in range) with exceptions") {
|
TEST_CASE("converter test ss:ir restriction (in range) with exceptions") {
|
||||||
// TODO remove ss::string_error
|
// TODO remove ss::string_error
|
||||||
ss::converter<ss::string_error, ss::throw_on_error> c;
|
ss::converter<ss::throw_on_error> c;
|
||||||
|
|
||||||
REQUIRE_EXCEPTION(c.convert<ss::ir<int, 0, 2>>("3"));
|
REQUIRE_EXCEPTION(c.convert<ss::ir<int, 0, 2>>("3"));
|
||||||
REQUIRE_EXCEPTION(c.convert<char, ss::ir<int, 4, 69>>("c,3"));
|
REQUIRE_EXCEPTION(c.convert<char, ss::ir<int, 4, 69>>("c,3"));
|
||||||
@ -523,7 +522,7 @@ TEST_CASE("converter test ss:ir restriction (in range) with exceptions") {
|
|||||||
CHECK_EQ(tup, std::make_tuple(1, 'c'));
|
CHECK_EQ(tup, std::make_tuple(1, 'c'));
|
||||||
}
|
}
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -563,7 +562,7 @@ TEST_CASE("converter test ss:oor restriction (out of range)") {
|
|||||||
|
|
||||||
TEST_CASE("converter test ss:oor restriction (out of range) with exceptions") {
|
TEST_CASE("converter test ss:oor restriction (out of range) with exceptions") {
|
||||||
// TODO remove ss::string_error
|
// TODO remove ss::string_error
|
||||||
ss::converter<ss::string_error, ss::throw_on_error> c;
|
ss::converter<ss::throw_on_error> c;
|
||||||
|
|
||||||
REQUIRE_EXCEPTION(c.convert<ss::oor<int, 1, 5>>("3"));
|
REQUIRE_EXCEPTION(c.convert<ss::oor<int, 1, 5>>("3"));
|
||||||
REQUIRE_EXCEPTION(c.convert<ss::oor<int, 0, 2>>("2"));
|
REQUIRE_EXCEPTION(c.convert<ss::oor<int, 0, 2>>("2"));
|
||||||
@ -589,7 +588,7 @@ TEST_CASE("converter test ss:oor restriction (out of range) with exceptions") {
|
|||||||
CHECK_EQ(tup, std::make_tuple(3, 'c'));
|
CHECK_EQ(tup, std::make_tuple(3, 'c'));
|
||||||
}
|
}
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -643,7 +642,7 @@ TEST_CASE("converter test ss:ne restriction (not empty)") {
|
|||||||
|
|
||||||
TEST_CASE("converter test ss:ne restriction (not empty) with exceptions") {
|
TEST_CASE("converter test ss:ne restriction (not empty) with exceptions") {
|
||||||
// TODO remove ss::string_error
|
// TODO remove ss::string_error
|
||||||
ss::converter<ss::string_error, ss::throw_on_error> c;
|
ss::converter<ss::throw_on_error> c;
|
||||||
|
|
||||||
REQUIRE_EXCEPTION(c.convert<ss::ne<std::string>>(""));
|
REQUIRE_EXCEPTION(c.convert<ss::ne<std::string>>(""));
|
||||||
REQUIRE_EXCEPTION(c.convert<int, ss::ne<std::string>>("3,"));
|
REQUIRE_EXCEPTION(c.convert<int, ss::ne<std::string>>("3,"));
|
||||||
@ -669,7 +668,7 @@ TEST_CASE("converter test ss:ne restriction (not empty) with exceptions") {
|
|||||||
CHECK_EQ(tup, extracted_vector);
|
CHECK_EQ(tup, extracted_vector);
|
||||||
}
|
}
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -735,7 +734,7 @@ TEST_CASE(
|
|||||||
TEST_CASE("converter test ss:lt ss::lte ss::gt ss::gte restriction (in range) "
|
TEST_CASE("converter test ss:lt ss::lte ss::gt ss::gte restriction (in range) "
|
||||||
"with exception") {
|
"with exception") {
|
||||||
// TODO remove ss::string_error
|
// TODO remove ss::string_error
|
||||||
ss::converter<ss::string_error, ss::throw_on_error> c;
|
ss::converter<ss::throw_on_error> c;
|
||||||
|
|
||||||
REQUIRE_EXCEPTION(c.convert<ss::lt<int, 3>>("3"));
|
REQUIRE_EXCEPTION(c.convert<ss::lt<int, 3>>("3"));
|
||||||
REQUIRE_EXCEPTION(c.convert<ss::lt<int, 2>>("3"));
|
REQUIRE_EXCEPTION(c.convert<ss::lt<int, 2>>("3"));
|
||||||
@ -781,7 +780,7 @@ TEST_CASE("converter test ss:lt ss::lte ss::gt ss::gte restriction (in range) "
|
|||||||
CHECK_EQ(tup, 3);
|
CHECK_EQ(tup, 3);
|
||||||
}
|
}
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -794,7 +793,7 @@ TEST_CASE("converter test error mode") {
|
|||||||
|
|
||||||
TEST_CASE("converter test throw on error mode") {
|
TEST_CASE("converter test throw on error mode") {
|
||||||
// TODO remove ss::string_error
|
// TODO remove ss::string_error
|
||||||
ss::converter<ss::string_error, ss::throw_on_error> c;
|
ss::converter<ss::throw_on_error> c;
|
||||||
REQUIRE_EXCEPTION(c.convert<int>("junk"));
|
REQUIRE_EXCEPTION(c.convert<int>("junk"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -849,14 +848,14 @@ TEST_CASE("converter test converter with quotes spacing and escaping with "
|
|||||||
"exceptions") {
|
"exceptions") {
|
||||||
// TODO remove ss::string_error on all below
|
// TODO remove ss::string_error on all below
|
||||||
try {
|
try {
|
||||||
ss::converter<ss::string_error, ss::throw_on_error> c;
|
ss::converter<ss::throw_on_error> c;
|
||||||
|
|
||||||
auto tup = c.convert<std::string, std::string, std::string>(
|
auto tup = c.convert<std::string, std::string, std::string>(
|
||||||
R"("just","some","strings")");
|
R"("just","some","strings")");
|
||||||
REQUIRE(c.valid());
|
REQUIRE(c.valid());
|
||||||
CHECK_EQ(tup, std::make_tuple("\"just\"", "\"some\"", "\"strings\""));
|
CHECK_EQ(tup, std::make_tuple("\"just\"", "\"some\"", "\"strings\""));
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -867,34 +866,34 @@ TEST_CASE("converter test converter with quotes spacing and escaping with "
|
|||||||
REQUIRE(c.valid());
|
REQUIRE(c.valid());
|
||||||
CHECK_EQ(tup, std::make_tuple("just", "some", 12.3, 'a'));
|
CHECK_EQ(tup, std::make_tuple("just", "some", 12.3, 'a'));
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ss::converter<ss::string_error, ss::throw_on_error, ss::trim<' '>> c;
|
ss::converter<ss::throw_on_error, ss::trim<' '>> c;
|
||||||
|
|
||||||
auto tup = c.convert<std::string, std::string, double, char>(
|
auto tup = c.convert<std::string, std::string, double, char>(
|
||||||
buff(R"( just , some , 12.3 ,a )"));
|
buff(R"( just , some , 12.3 ,a )"));
|
||||||
REQUIRE(c.valid());
|
REQUIRE(c.valid());
|
||||||
CHECK_EQ(tup, std::make_tuple("just", "some", 12.3, 'a'));
|
CHECK_EQ(tup, std::make_tuple("just", "some", 12.3, 'a'));
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ss::converter<ss::string_error, ss::throw_on_error, ss::escape<'\\'>> c;
|
ss::converter<ss::throw_on_error, ss::escape<'\\'>> c;
|
||||||
|
|
||||||
auto tup =
|
auto tup =
|
||||||
c.convert<std::string, std::string>(buff(R"(ju\,st,strings)"));
|
c.convert<std::string, std::string>(buff(R"(ju\,st,strings)"));
|
||||||
REQUIRE(c.valid());
|
REQUIRE(c.valid());
|
||||||
CHECK_EQ(tup, std::make_tuple("ju,st", "strings"));
|
CHECK_EQ(tup, std::make_tuple("ju,st", "strings"));
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ss::converter<ss::string_error, ss::throw_on_error, ss::escape<'\\'>,
|
ss::converter<ss::throw_on_error, ss::escape<'\\'>, ss::trim<' '>,
|
||||||
ss::trim<' '>, ss::quote<'"'>>
|
ss::quote<'"'>>
|
||||||
c;
|
c;
|
||||||
|
|
||||||
auto tup = c.convert<std::string, std::string, double, std::string>(
|
auto tup = c.convert<std::string, std::string, double, std::string>(
|
||||||
@ -902,7 +901,7 @@ TEST_CASE("converter test converter with quotes spacing and escaping with "
|
|||||||
REQUIRE(c.valid());
|
REQUIRE(c.valid());
|
||||||
CHECK_EQ(tup, std::make_tuple("ju,st", "so,me", 12.34, "str\"ings"));
|
CHECK_EQ(tup, std::make_tuple("ju,st", "so,me", 12.34, "str\"ings"));
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -959,8 +958,8 @@ TEST_CASE("converter test invalid split conversions") {
|
|||||||
|
|
||||||
TEST_CASE("converter test invalid split conversions with exceptions") {
|
TEST_CASE("converter test invalid split conversions with exceptions") {
|
||||||
// TODO remove ss::string_error
|
// TODO remove ss::string_error
|
||||||
ss::converter<ss::string_error, ss::escape<'\\'>, ss::trim<' '>,
|
ss::converter<ss::escape<'\\'>, ss::trim<' '>, ss::quote<'"'>,
|
||||||
ss::quote<'"'>, ss::throw_on_error>
|
ss::throw_on_error>
|
||||||
c;
|
c;
|
||||||
|
|
||||||
// mismatched quote
|
// mismatched quote
|
||||||
|
@ -856,6 +856,7 @@ TEST_CASE("parser test multiline restricted") {
|
|||||||
for (auto& [_, __, s] : i) {
|
for (auto& [_, __, s] : i) {
|
||||||
update_if_crlf(s);
|
update_if_crlf(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK_EQ(i, data);
|
CHECK_EQ(i, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ void test_combinations(matches_type& matches, std::vector<std::string> delims) {
|
|||||||
auto vec = st.split(buff(lines[i].c_str()), delim);
|
auto vec = st.split(buff(lines[i].c_str()), delim);
|
||||||
CHECK_EQ(words(vec), expectations[i]);
|
CHECK_EQ(words(vec), expectations[i]);
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -520,8 +520,7 @@ TEST_CASE("splitter test error mode") {
|
|||||||
CHECK_FALSE(s.error_msg().empty());
|
CHECK_FALSE(s.error_msg().empty());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// TODO remove ss::string_error
|
ss::splitter<ss::throw_on_error> s;
|
||||||
ss::splitter<ss::string_error, ss::throw_on_error> s;
|
|
||||||
s.split(buff("just,some,strings"), "");
|
s.split(buff("just,some,strings"), "");
|
||||||
FAIL("expected exception");
|
FAIL("expected exception");
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
@ -544,12 +543,12 @@ template <typename Splitter>
|
|||||||
auto expect_unterminated_quote(Splitter& s, const std::string& line) {
|
auto expect_unterminated_quote(Splitter& s, const std::string& line) {
|
||||||
try {
|
try {
|
||||||
auto vec = s.split(buff(line.c_str()));
|
auto vec = s.split(buff(line.c_str()));
|
||||||
CHECK_FALSE(s.valid());
|
CHECK(s.valid());
|
||||||
CHECK(s.unterminated_quote());
|
CHECK(s.unterminated_quote());
|
||||||
return vec;
|
return vec;
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
// TODO check if this is ok
|
// TODO check if this is ok
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
return decltype(s.split(buff(line.c_str()))){};
|
return decltype(s.split(buff(line.c_str()))){};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -658,7 +657,7 @@ TEST_CASE("splitter test resplit unterminated quote") {
|
|||||||
{
|
{
|
||||||
auto new_line = buff.append(R"(,dom)");
|
auto new_line = buff.append(R"(,dom)");
|
||||||
vec = c.resplit(new_line, strlen(new_line));
|
vec = c.resplit(new_line, strlen(new_line));
|
||||||
CHECK_FALSE(s.valid());
|
CHECK(s.valid());
|
||||||
CHECK(s.unterminated_quote());
|
CHECK(s.unterminated_quote());
|
||||||
CHECK_EQ(words(vec), expected);
|
CHECK_EQ(words(vec), expected);
|
||||||
}
|
}
|
||||||
@ -808,7 +807,6 @@ TEST_CASE("splitter test resplit unterminated quote with exceptions") {
|
|||||||
auto vec = expect_unterminated_quote(s, R"("x)");
|
auto vec = expect_unterminated_quote(s, R"("x)");
|
||||||
|
|
||||||
CHECK_EQ(vec.size(), 1);
|
CHECK_EQ(vec.size(), 1);
|
||||||
|
|
||||||
REQUIRE(s.unterminated_quote());
|
REQUIRE(s.unterminated_quote());
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -832,7 +830,7 @@ TEST_CASE("splitter test resplit unterminated quote with exceptions") {
|
|||||||
CHECK_EQ(words(vec)[0], "xax");
|
CHECK_EQ(words(vec)[0], "xax");
|
||||||
}
|
}
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -848,7 +846,7 @@ TEST_CASE("splitter test resplit unterminated quote with exceptions") {
|
|||||||
std::vector<std::string> expected{"just", "strings"};
|
std::vector<std::string> expected{"just", "strings"};
|
||||||
CHECK_EQ(words(vec), expected);
|
CHECK_EQ(words(vec), expected);
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -865,7 +863,7 @@ TEST_CASE("splitter test resplit unterminated quote with exceptions") {
|
|||||||
expected = {"just", "some", "random", "strings"};
|
expected = {"just", "some", "random", "strings"};
|
||||||
CHECK_EQ(words(vec), expected);
|
CHECK_EQ(words(vec), expected);
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -883,7 +881,7 @@ TEST_CASE("splitter test resplit unterminated quote with exceptions") {
|
|||||||
expected = {"just", "some", "ran\",dom", "strings"};
|
expected = {"just", "some", "ran\",dom", "strings"};
|
||||||
CHECK_EQ(words(vec), expected);
|
CHECK_EQ(words(vec), expected);
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -897,7 +895,7 @@ TEST_CASE("splitter test resplit unterminated quote with exceptions") {
|
|||||||
{
|
{
|
||||||
auto new_line = buff.append(R"(,dom)");
|
auto new_line = buff.append(R"(,dom)");
|
||||||
vec = c.resplit(new_line, strlen(new_line));
|
vec = c.resplit(new_line, strlen(new_line));
|
||||||
CHECK_FALSE(s.valid());
|
CHECK(s.valid());
|
||||||
CHECK(s.unterminated_quote());
|
CHECK(s.unterminated_quote());
|
||||||
CHECK_EQ(words(vec), expected);
|
CHECK_EQ(words(vec), expected);
|
||||||
}
|
}
|
||||||
@ -911,7 +909,7 @@ TEST_CASE("splitter test resplit unterminated quote with exceptions") {
|
|||||||
CHECK_EQ(words(vec), expected);
|
CHECK_EQ(words(vec), expected);
|
||||||
}
|
}
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -934,7 +932,7 @@ TEST_CASE("splitter test resplit unterminated quote with exceptions") {
|
|||||||
CHECK_EQ(words(vec), expected);
|
CHECK_EQ(words(vec), expected);
|
||||||
}
|
}
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -961,7 +959,7 @@ TEST_CASE("splitter test resplit unterminated quote with exceptions") {
|
|||||||
CHECK_EQ(words(vec), expected);
|
CHECK_EQ(words(vec), expected);
|
||||||
}
|
}
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -985,7 +983,7 @@ TEST_CASE("splitter test resplit unterminated quote with exceptions") {
|
|||||||
CHECK_EQ(words(vec), expected);
|
CHECK_EQ(words(vec), expected);
|
||||||
}
|
}
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -1009,7 +1007,7 @@ TEST_CASE("splitter test resplit unterminated quote with exceptions") {
|
|||||||
CHECK_EQ(words(vec), expected);
|
CHECK_EQ(words(vec), expected);
|
||||||
}
|
}
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -1032,7 +1030,7 @@ TEST_CASE("splitter test resplit unterminated quote with exceptions") {
|
|||||||
CHECK_EQ(words(vec), expected);
|
CHECK_EQ(words(vec), expected);
|
||||||
}
|
}
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -1057,7 +1055,7 @@ TEST_CASE("splitter test resplit unterminated quote with exceptions") {
|
|||||||
CHECK_EQ(words(vec), expected);
|
CHECK_EQ(words(vec), expected);
|
||||||
}
|
}
|
||||||
} catch (ss::exception& e) {
|
} catch (ss::exception& e) {
|
||||||
FAIL(e.what());
|
FAIL(std::string{e.what()});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1106,8 +1104,8 @@ TEST_CASE("splitter test invalid splits") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("splitter test invalid splits with exceptions") {
|
TEST_CASE("splitter test invalid splits with exceptions") {
|
||||||
ss::converter<ss::string_error, ss::quote<'"'>, ss::trim<' '>,
|
ss::converter<ss::throw_on_error, ss::quote<'"'>, ss::trim<' '>,
|
||||||
ss::escape<'\\'>, ss::throw_on_error>
|
ss::escape<'\\'>>
|
||||||
c;
|
c;
|
||||||
auto& s = c.splitter;
|
auto& s = c.splitter;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user