diff --git a/cpp/tests/utilities/column_utilities.cu b/cpp/tests/utilities/column_utilities.cu index fcaf23fd456..bae402155e9 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,8 +1099,13 @@ struct column_view_printer { out.replace(pos, 1, repl); } }; + replace_char(out, '\a', "\\a"); + replace_char(out, '\b', "\\b"); + 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 e90a3f9ac6e..90a7270cb29 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é", "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); +} + TYPED_TEST(ColumnUtilitiesTestFixedPoint, NonNullableToHost) { using namespace numeric;