WIP, Continue writing additional parser tests

This commit is contained in:
ado 2023-07-29 22:57:33 +02:00
parent 37f1fb534f
commit ba45fe1839

View File

@ -139,12 +139,14 @@ std::vector<std::string> generate_csv_data(const std::vector<field>& data,
#ifdef _WIN32 #ifdef _WIN32
constexpr static auto new_line = "\r\n"; constexpr static auto new_line = "\r\n";
#else #else
constexpr static auto new_line = '\n'; constexpr static auto new_line = "\n";
#endif #endif
constexpr static auto helper0 = '#'; constexpr static auto helper0 = '#';
constexpr static auto helper1 = '$'; constexpr static auto helper1 = '$';
// constexpr static auto helper3 = '&'; // constexpr static auto helper3 = '&';
auto escape_s = std::string{escape};
std::vector<std::string> output; std::vector<std::string> output;
if (setup::escape::enabled && setup::quote::enabled) { if (setup::escape::enabled && setup::quote::enabled) {
@ -162,7 +164,7 @@ std::vector<std::string> generate_csv_data(const std::vector<field>& data,
rng.rand_insert_n(value, escape, 2); rng.rand_insert_n(value, escape, 2);
if (!quote_newline) { if (!quote_newline) {
replace_all2(value, {new_line}, {helper1}); replace_all2(value, {new_line}, {helper1});
replace_all2(value, {helper1}, {escape, new_line}); replace_all2(value, {helper1}, {escape_s + new_line});
} }
replace_all2(value, {escape, escape}, {escape}); replace_all2(value, {escape, escape}, {escape});
replace_all2(value, {escape, helper0}, {helper0}); replace_all2(value, {escape, helper0}, {helper0});
@ -201,7 +203,7 @@ std::vector<std::string> generate_csv_data(const std::vector<field>& data,
replace_all2(value, {escape}, {helper0}); replace_all2(value, {escape}, {helper0});
rng.rand_insert_n(value, escape, 3); rng.rand_insert_n(value, escape, 3);
replace_all2(value, {new_line}, {helper1}); replace_all2(value, {new_line}, {helper1});
replace_all2(value, {helper1}, {escape, new_line}); replace_all2(value, {helper1}, {escape_s + new_line});
replace_all2(value, {escape, escape}, {escape}); replace_all2(value, {escape, escape}, {escape});
replace_all2(value, {escape, helper0}, {helper0}); replace_all2(value, {escape, helper0}, {helper0});