From 538283c6db589a25522c02e0ad751a70fd48fb5a Mon Sep 17 00:00:00 2001 From: David Wendt Date: Tue, 29 Aug 2023 12:11:49 -0400 Subject: [PATCH 1/2] Add tab as literal to cudf::test::print output --- cpp/tests/utilities/column_utilities.cu | 4 +++- cpp/tests/utilities_tests/column_utilities_tests.cpp | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/cpp/tests/utilities/column_utilities.cu b/cpp/tests/utilities/column_utilities.cu index fcaf23fd456..e48e755a2d5 100644 --- a/cpp/tests/utilities/column_utilities.cu +++ b/cpp/tests/utilities/column_utilities.cu @@ -1091,7 +1091,7 @@ struct column_view_printer { if (col.is_empty()) return; auto h_data = cudf::test::to_host(col); - // explicitly replace '\r' and '\n' characters with "\r" and "\n" strings respectively. + // explicitly replace some special whitespace characters with their literal equivalents auto cleaned = [](std::string_view in) { std::string out(in); auto replace_char = [](std::string& out, char c, std::string_view repl) { @@ -1099,6 +1099,8 @@ struct column_view_printer { out.replace(pos, 1, repl); } }; + replace_char(out, '\b', "\\b"); + replace_char(out, '\t', "\\t"); replace_char(out, '\r', "\\r"); replace_char(out, '\n', "\\n"); return out; diff --git a/cpp/tests/utilities_tests/column_utilities_tests.cpp b/cpp/tests/utilities_tests/column_utilities_tests.cpp index e90a3f9ac6e..7b0c3c703f5 100644 --- a/cpp/tests/utilities_tests/column_utilities_tests.cpp +++ b/cpp/tests/utilities_tests/column_utilities_tests.cpp @@ -274,6 +274,14 @@ TEST_F(ColumnUtilitiesStringsTest, StringsToString) EXPECT_EQ(cudf::test::to_string(strings, delimiter), tmp.str()); } +TEST_F(ColumnUtilitiesStringsTest, PrintEscapeStrings) +{ + char const* delimiter = ","; + cudf::test::strings_column_wrapper input({"e\te\ne", "é\bé\ré"}); + std::string expected{"e\\te\\ne,é\\bé\\ré"}; + EXPECT_EQ(cudf::test::to_string(input, delimiter), expected); +} + TYPED_TEST(ColumnUtilitiesTestFixedPoint, NonNullableToHost) { using namespace numeric; From d3352180ecef3d16ddb21e9b341c4b71629c2162 Mon Sep 17 00:00:00 2001 From: David Wendt Date: Tue, 29 Aug 2023 12:52:34 -0400 Subject: [PATCH 2/2] add a few more escaped types --- cpp/tests/utilities/column_utilities.cu | 5 ++++- cpp/tests/utilities_tests/column_utilities_tests.cpp | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cpp/tests/utilities/column_utilities.cu b/cpp/tests/utilities/column_utilities.cu index e48e755a2d5..bae402155e9 100644 --- a/cpp/tests/utilities/column_utilities.cu +++ b/cpp/tests/utilities/column_utilities.cu @@ -1099,10 +1099,13 @@ struct column_view_printer { out.replace(pos, 1, repl); } }; + replace_char(out, '\a', "\\a"); replace_char(out, '\b', "\\b"); - replace_char(out, '\t', "\\t"); + replace_char(out, '\f', "\\f"); replace_char(out, '\r', "\\r"); + replace_char(out, '\t', "\\t"); replace_char(out, '\n', "\\n"); + replace_char(out, '\v', "\\v"); return out; }; diff --git a/cpp/tests/utilities_tests/column_utilities_tests.cpp b/cpp/tests/utilities_tests/column_utilities_tests.cpp index 7b0c3c703f5..90a7270cb29 100644 --- a/cpp/tests/utilities_tests/column_utilities_tests.cpp +++ b/cpp/tests/utilities_tests/column_utilities_tests.cpp @@ -277,8 +277,8 @@ TEST_F(ColumnUtilitiesStringsTest, StringsToString) TEST_F(ColumnUtilitiesStringsTest, PrintEscapeStrings) { char const* delimiter = ","; - cudf::test::strings_column_wrapper input({"e\te\ne", "é\bé\ré"}); - std::string expected{"e\\te\\ne,é\\bé\\ré"}; + cudf::test::strings_column_wrapper input({"e\te\ne", "é\bé\ré", "e\vé\fé\abell"}); + std::string expected{"e\\te\\ne,é\\bé\\ré,e\\vé\\fé\\abell"}; EXPECT_EQ(cudf::test::to_string(input, delimiter), expected); }