diff options
| author | innokentii <[email protected]> | 2023-02-01 16:01:14 +0300 |
|---|---|---|
| committer | innokentii <[email protected]> | 2023-02-01 16:01:14 +0300 |
| commit | 96b135245109ad10d4e6a51d9f7fa61add23e839 (patch) | |
| tree | 754dd793a8952d93f8da462c781404f3563114f8 /library/cpp/yaml/fyamlcpp/fyamlcpp_ut.cpp | |
| parent | acce22d4812c919616875de449eb6eb69006593a (diff) | |
Add basic yaml config resolver
Diffstat (limited to 'library/cpp/yaml/fyamlcpp/fyamlcpp_ut.cpp')
| -rw-r--r-- | library/cpp/yaml/fyamlcpp/fyamlcpp_ut.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/library/cpp/yaml/fyamlcpp/fyamlcpp_ut.cpp b/library/cpp/yaml/fyamlcpp/fyamlcpp_ut.cpp new file mode 100644 index 00000000000..f9aab7b011b --- /dev/null +++ b/library/cpp/yaml/fyamlcpp/fyamlcpp_ut.cpp @@ -0,0 +1,53 @@ +#include "fyamlcpp.h" + +#include <contrib/libs/libfyaml/include/libfyaml.h> + +#include <library/cpp/testing/unittest/registar.h> + +#include <util/stream/str.h> + +Y_UNIT_TEST_SUITE(FYamlCpp) { + Y_UNIT_TEST(EnumEquals) { + UNIT_ASSERT_EQUAL((int)NFyaml::ENodeType::Scalar, FYNT_SCALAR); + UNIT_ASSERT_EQUAL((int)NFyaml::ENodeType::Sequence, FYNT_SEQUENCE); + UNIT_ASSERT_EQUAL((int)NFyaml::ENodeType::Mapping, FYNT_MAPPING); + } + + Y_UNIT_TEST(ErrorHandling) { + { + const char *yaml = R"( +config: a +config: b +)"; + UNIT_ASSERT_EXCEPTION_CONTAINS( + NFyaml::TDocument::Parse(yaml), + yexception, + "3:1 duplicate key"); + } + + { + const char *yaml = R"( +anchor: *does_not_exists +)"; + auto doc = NFyaml::TDocument::Parse(yaml); + UNIT_ASSERT_EXCEPTION_CONTAINS( + doc.Resolve(), + yexception, + "2:10 invalid alias"); + } + } + + Y_UNIT_TEST(Out) { + const char *yaml = R"( +test: output +)"; + + auto doc = NFyaml::TDocument::Parse(yaml); + + TStringStream ss; + + ss << doc; + + UNIT_ASSERT_VALUES_EQUAL(ss.Str(), "test: output\n"); + } +} |
