From 4dea553457efda88fef237809afb5b9a95da7d41 Mon Sep 17 00:00:00 2001 From: bulatman <bulatman@yandex-team.com> Date: Thu, 1 Jun 2023 10:15:45 +0300 Subject: YT: Fix ParseEnum when custom domain names used --- library/cpp/yt/string/unittests/enum_ut.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'library/cpp/yt/string/unittests/enum_ut.cpp') diff --git a/library/cpp/yt/string/unittests/enum_ut.cpp b/library/cpp/yt/string/unittests/enum_ut.cpp index fed6d6eb21..f30aec1cab 100644 --- a/library/cpp/yt/string/unittests/enum_ut.cpp +++ b/library/cpp/yt/string/unittests/enum_ut.cpp @@ -29,6 +29,11 @@ DEFINE_BIT_ENUM(ELangs, ((JavaScript) (0x10)) ); +DEFINE_ENUM(ECustomDomainName, + ((A) (1) ("value_a")) + ((B) (2) ("value_b")) +); + TEST(TFormatTest, Enum) { EXPECT_EQ("Red", Format("%v", EColor::Red)); @@ -53,6 +58,19 @@ TEST(TFormatTest, Enum) EXPECT_EQ("cpp | go | python | java_script", Format("%lv", four)); } +TEST(TFormatEnumTest, FormatEnumWithCustomDomainName) +{ + EXPECT_EQ("value_a", FormatEnum(ECustomDomainName::A)); + EXPECT_EQ("value_b", FormatEnum(ECustomDomainName::B)); +} + +TEST(TParseEnumTest, ParseEnumWithCustomDomainName) +{ + EXPECT_EQ(ECustomDomainName::A, TryParseEnum<ECustomDomainName>("value_a")); + EXPECT_EQ(ECustomDomainName::B, TryParseEnum<ECustomDomainName>("value_b")); + EXPECT_EQ(std::nullopt, TryParseEnum<ECustomDomainName>("b")); +} + //////////////////////////////////////////////////////////////////////////////// } // namespace -- cgit v1.2.3