diff options
author | uzhas <uzhas@ydb.tech> | 2023-07-13 17:26:04 +0300 |
---|---|---|
committer | uzhas <uzhas@ydb.tech> | 2023-07-13 17:26:04 +0300 |
commit | 61a929f4478b06d131deaf8b31be01277bcc35ee (patch) | |
tree | 1b9993e19fcbdd962c949aaba55b807359007510 | |
parent | 7f4386ea75e9b9c64fe6db4a11acadc8016a584a (diff) | |
download | ydb-61a929f4478b06d131deaf8b31be01277bcc35ee.tar.gz |
add more tests for string value with quotes in results
-rw-r--r-- | ydb/core/fq/libs/result_formatter/result_formatter_ut.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/ydb/core/fq/libs/result_formatter/result_formatter_ut.cpp b/ydb/core/fq/libs/result_formatter/result_formatter_ut.cpp index ed05808b23..9bd432889b 100644 --- a/ydb/core/fq/libs/result_formatter/result_formatter_ut.cpp +++ b/ydb/core/fq/libs/result_formatter/result_formatter_ut.cpp @@ -60,6 +60,49 @@ Y_UNIT_TEST_SUITE(ResultFormatter) { } } + Y_UNIT_TEST(Utf8WithQuotes) { + Ydb::ResultSet rs; + { + auto& column = *rs.add_columns(); + column.set_name("column0"); + auto& type = *column.mutable_type(); + type.set_type_id(Ydb::Type::UTF8); + } + { + auto& value = *rs.add_rows(); + value.add_items()->set_text_value("he\"llo"); + } + + { + NJson::TJsonValue root; + FormatResultSet(root, rs); + + TStringStream stream; + NJson::WriteJson(&stream, &root); + + // Cerr << stream.Str() << Endl; + + TString expected = R"___({"data":[{"column0":"he\"llo"}],"columns":[{"name":"column0","type":["DataType","Utf8"]}]})___"; + + UNIT_ASSERT_VALUES_EQUAL(stream.Str(), expected); + } + + // pretty format + { + NJson::TJsonValue root; + FormatResultSet(root, rs, true, true); + + TStringStream stream; + NJson::WriteJson(&stream, &root); + + // Cerr << stream.Str() << Endl; + + TString expected = R"___({"data":[["he\"llo"]],"columns":[{"name":"column0","type":"Utf8"}]})___"; + + UNIT_ASSERT_VALUES_EQUAL(stream.Str(), expected); + } + } + Y_UNIT_TEST(List) { Ydb::ResultSet rs; { |