aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yaml
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
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')
-rw-r--r--library/cpp/yaml/as/tstring.h54
-rw-r--r--library/cpp/yaml/as/ut/tstring_test.cpp116
-rw-r--r--library/cpp/yaml/as/ut/ya.make28
-rw-r--r--library/cpp/yaml/as/ya.make26
-rw-r--r--library/cpp/yaml/ya.make6
5 files changed, 115 insertions, 115 deletions
diff --git a/library/cpp/yaml/as/tstring.h b/library/cpp/yaml/as/tstring.h
index 454bcb336c..1037e46706 100644
--- a/library/cpp/yaml/as/tstring.h
+++ b/library/cpp/yaml/as/tstring.h
@@ -1,27 +1,27 @@
-#pragma once
-
-#include <contrib/libs/yaml-cpp/include/yaml-cpp/yaml.h>
-
-#include <util/generic/string.h>
-
-namespace YAML {
- template <>
- inline TString Node::as<TString>() const {
- const auto& converted = as<std::string>();
- return TString(converted.c_str(), converted.size());
- }
-
- template <>
- struct convert<TString> {
- static Node encode(const TString& rhs) {
- return Node(std::string(rhs));
- }
-
- static bool decode(const Node& node, TString& rhs) {
- if (!node.IsScalar())
- return false;
- rhs = node.Scalar();
- return true;
- }
- };
-}
+#pragma once
+
+#include <contrib/libs/yaml-cpp/include/yaml-cpp/yaml.h>
+
+#include <util/generic/string.h>
+
+namespace YAML {
+ template <>
+ inline TString Node::as<TString>() const {
+ const auto& converted = as<std::string>();
+ return TString(converted.c_str(), converted.size());
+ }
+
+ template <>
+ struct convert<TString> {
+ static Node encode(const TString& rhs) {
+ return Node(std::string(rhs));
+ }
+
+ static bool decode(const Node& node, TString& rhs) {
+ if (!node.IsScalar())
+ return false;
+ rhs = node.Scalar();
+ return true;
+ }
+ };
+}
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()
diff --git a/library/cpp/yaml/as/ya.make b/library/cpp/yaml/as/ya.make
index 83598b8e8a..80d60b957b 100644
--- a/library/cpp/yaml/as/ya.make
+++ b/library/cpp/yaml/as/ya.make
@@ -1,13 +1,13 @@
-LIBRARY()
-
-OWNER(g:crypta)
-
-PEERDIR(
- contrib/libs/yaml-cpp
-)
-
-END()
-
-RECURSE_FOR_TESTS(
- ut
-)
+LIBRARY()
+
+OWNER(g:crypta)
+
+PEERDIR(
+ contrib/libs/yaml-cpp
+)
+
+END()
+
+RECURSE_FOR_TESTS(
+ ut
+)
diff --git a/library/cpp/yaml/ya.make b/library/cpp/yaml/ya.make
index dd1b2a4c0e..e9689fe65b 100644
--- a/library/cpp/yaml/ya.make
+++ b/library/cpp/yaml/ya.make
@@ -1,4 +1,4 @@
-RECURSE(
- as
+RECURSE(
+ as
scheme
-)
+)