aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yaml/as/ut
diff options
context:
space:
mode:
authorAndrey Rogozhnikov <rogozhnikov.andrey@gmail.com>2022-02-10 16:50:02 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:50:02 +0300
commit0d6462b7e878d92e0a81ff7d47886837220f4a1a (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/yaml/as/ut
parent3a00a7f47463f54c5c60c205eac7ab320572e930 (diff)
downloadydb-0d6462b7e878d92e0a81ff7d47886837220f4a1a.tar.gz
Restoring authorship annotation for Andrey Rogozhnikov <rogozhnikov.andrey@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/yaml/as/ut')
-rw-r--r--library/cpp/yaml/as/ut/tstring_test.cpp116
-rw-r--r--library/cpp/yaml/as/ut/ya.make28
2 files changed, 72 insertions, 72 deletions
diff --git a/library/cpp/yaml/as/ut/tstring_test.cpp b/library/cpp/yaml/as/ut/tstring_test.cpp
index cf1af06296..2ad4f6c572 100644
--- a/library/cpp/yaml/as/ut/tstring_test.cpp
+++ b/library/cpp/yaml/as/ut/tstring_test.cpp
@@ -1,59 +1,59 @@
#include <library/cpp/testing/unittest/registar.h>
-#include <library/cpp/yaml/as/tstring.h>
-
-#include <contrib/libs/yaml-cpp/include/yaml-cpp/yaml.h>
-
-#include <array>
-
-Y_UNIT_TEST_SUITE(YamlTstringTest) {
- Y_UNIT_TEST(As) {
- const auto* key1 = "key1";
- const auto* key2 = "key2";
- const TString string = "string";
- const TString anotherString = "another string";
-
- YAML::Node map;
- map[key1] = std::string(string);
-
- UNIT_ASSERT_VALUES_EQUAL(map[key1].as<TString>(), string);
- UNIT_ASSERT_VALUES_EQUAL(map[key1].as<TString>(anotherString), string);
-
- UNIT_ASSERT_VALUES_EQUAL(map[key2].as<TString>(anotherString), anotherString);
-
- UNIT_ASSERT_EXCEPTION(map[key1].as<int>(), YAML::BadConversion);
-
- UNIT_ASSERT_EXCEPTION(map[key2].as<int>(), YAML::BadConversion);
- UNIT_ASSERT_EXCEPTION(map[key2].as<TString>(), YAML::BadConversion);
- }
-
- Y_UNIT_TEST(Convert) {
- const TString string("string");
- auto node = YAML::Node(std::string(string));
-
- UNIT_ASSERT_VALUES_EQUAL(node.Scalar(), YAML::convert<TString>::encode(string).Scalar());
-
- TString buffer;
- YAML::convert<TString>::decode(node, buffer);
- UNIT_ASSERT_VALUES_EQUAL(string, buffer);
- }
-
- Y_UNIT_TEST(NullCharactersInString) {
- const std::array<char, 3> characters = {{'a', '\0', 'b'}};
- const std::string testString(characters.data(), characters.size());
- const TString refString(characters.data(), characters.size());
- const std::string key = "key";
-
- YAML::Node node;
- node[key] = testString;
-
- UNIT_ASSERT_VALUES_EQUAL(node[key].as<TString>(), refString);
- UNIT_ASSERT_VALUES_EQUAL(node[key].as<TString>(TString("fallback")), refString);
-
- auto stringNode = YAML::Node(testString);
- UNIT_ASSERT_VALUES_EQUAL(stringNode.Scalar(), YAML::convert<TString>::encode(refString).Scalar());
-
- TString buffer;
- YAML::convert<TString>::decode(stringNode, buffer);
- UNIT_ASSERT_VALUES_EQUAL(refString, buffer);
- }
-}
+#include <library/cpp/yaml/as/tstring.h>
+
+#include <contrib/libs/yaml-cpp/include/yaml-cpp/yaml.h>
+
+#include <array>
+
+Y_UNIT_TEST_SUITE(YamlTstringTest) {
+ Y_UNIT_TEST(As) {
+ const auto* key1 = "key1";
+ const auto* key2 = "key2";
+ const TString string = "string";
+ const TString anotherString = "another string";
+
+ YAML::Node map;
+ map[key1] = std::string(string);
+
+ UNIT_ASSERT_VALUES_EQUAL(map[key1].as<TString>(), string);
+ UNIT_ASSERT_VALUES_EQUAL(map[key1].as<TString>(anotherString), string);
+
+ UNIT_ASSERT_VALUES_EQUAL(map[key2].as<TString>(anotherString), anotherString);
+
+ UNIT_ASSERT_EXCEPTION(map[key1].as<int>(), YAML::BadConversion);
+
+ UNIT_ASSERT_EXCEPTION(map[key2].as<int>(), YAML::BadConversion);
+ UNIT_ASSERT_EXCEPTION(map[key2].as<TString>(), YAML::BadConversion);
+ }
+
+ Y_UNIT_TEST(Convert) {
+ const TString string("string");
+ auto node = YAML::Node(std::string(string));
+
+ UNIT_ASSERT_VALUES_EQUAL(node.Scalar(), YAML::convert<TString>::encode(string).Scalar());
+
+ TString buffer;
+ YAML::convert<TString>::decode(node, buffer);
+ UNIT_ASSERT_VALUES_EQUAL(string, buffer);
+ }
+
+ Y_UNIT_TEST(NullCharactersInString) {
+ const std::array<char, 3> characters = {{'a', '\0', 'b'}};
+ const std::string testString(characters.data(), characters.size());
+ const TString refString(characters.data(), characters.size());
+ const std::string key = "key";
+
+ YAML::Node node;
+ node[key] = testString;
+
+ UNIT_ASSERT_VALUES_EQUAL(node[key].as<TString>(), refString);
+ UNIT_ASSERT_VALUES_EQUAL(node[key].as<TString>(TString("fallback")), refString);
+
+ auto stringNode = YAML::Node(testString);
+ UNIT_ASSERT_VALUES_EQUAL(stringNode.Scalar(), YAML::convert<TString>::encode(refString).Scalar());
+
+ TString buffer;
+ YAML::convert<TString>::decode(stringNode, buffer);
+ UNIT_ASSERT_VALUES_EQUAL(refString, buffer);
+ }
+}
diff --git a/library/cpp/yaml/as/ut/ya.make b/library/cpp/yaml/as/ut/ya.make
index 1e04e4c7b2..4eb394dd54 100644
--- a/library/cpp/yaml/as/ut/ya.make
+++ b/library/cpp/yaml/as/ut/ya.make
@@ -1,14 +1,14 @@
-UNITTEST()
-
-OWNER(g:crypta)
-
-SRCS(
- tstring_test.cpp
-)
-
-PEERDIR(
- contrib/libs/yaml-cpp
- library/cpp/yaml/as
-)
-
-END()
+UNITTEST()
+
+OWNER(g:crypta)
+
+SRCS(
+ tstring_test.cpp
+)
+
+PEERDIR(
+ contrib/libs/yaml-cpp
+ library/cpp/yaml/as
+)
+
+END()