aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbabenko <babenko@yandex-team.com>2024-10-26 23:13:30 +0300
committerbabenko <babenko@yandex-team.com>2024-10-26 23:30:14 +0300
commit41d598c624442bf6918407466dac3316b8277347 (patch)
tree5895b8823d4f887e1e5ab4f99cbac991dca5ca17
parentddabd4ddff87ac13bfc87ef02af352216a0f4e13 (diff)
downloadydb-41d598c624442bf6918407466dac3316b8277347.tar.gz
YT-22885: DEFINE_ENUM_UNKNOWN_VALUE, string-related conversions
commit_hash:14c7e42422af750383f04855b4a7ea6b267b92d2
-rw-r--r--library/cpp/yt/misc/enum-inl.h15
-rw-r--r--library/cpp/yt/misc/enum.h36
-rw-r--r--library/cpp/yt/misc/unittests/enum_ut.cpp13
-rw-r--r--library/cpp/yt/string/enum-inl.h112
-rw-r--r--library/cpp/yt/string/enum.cpp35
-rw-r--r--library/cpp/yt/string/enum.h4
-rw-r--r--library/cpp/yt/string/unittests/enum_ut.cpp46
-rw-r--r--yt/yt/core/misc/unittests/string_ut.cpp52
-rw-r--r--yt/yt/core/misc/unittests/ya.make1
-rw-r--r--yt/yt/core/ytree/unittests/serialize_ut.cpp16
10 files changed, 170 insertions, 160 deletions
diff --git a/library/cpp/yt/misc/enum-inl.h b/library/cpp/yt/misc/enum-inl.h
index 5e1d04da1f..6ad9273293 100644
--- a/library/cpp/yt/misc/enum-inl.h
+++ b/library/cpp/yt/misc/enum-inl.h
@@ -38,6 +38,14 @@ namespace NYT {
////////////////////////////////////////////////////////////////////////////////
+template <class T>
+constexpr std::optional<T> TryGetEnumUnknownValueImpl(T)
+{
+ return std::nullopt;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
namespace NDetail {
template <typename TValues>
@@ -262,6 +270,13 @@ TStringBuf TEnumTraits<T, true>::GetTypeName()
}
template <class T>
+constexpr std::optional<T> TEnumTraits<T, true>::TryGetUnknownValue()
+{
+ using NYT::TryGetEnumUnknownValueImpl;
+ return TryGetEnumUnknownValueImpl(T());
+}
+
+template <class T>
std::optional<T> TEnumTraits<T, true>::FindValueByLiteral(TStringBuf literal)
{
return TEnumTraitsImpl<T>::FindValueByLiteral(literal);
diff --git a/library/cpp/yt/misc/enum.h b/library/cpp/yt/misc/enum.h
index 4d40ab8ec4..f78d23a06d 100644
--- a/library/cpp/yt/misc/enum.h
+++ b/library/cpp/yt/misc/enum.h
@@ -33,18 +33,11 @@ template <class T>
using TEnumTraitsImpl = decltype(GetEnumTraitsImpl(T()));
template <class T>
-constexpr bool IsEnumDomainSizeKnown()
-{
- if constexpr(requires{ TEnumTraitsImpl<T>::DomainSize; }) {
- return true;
- } else {
- return false;
- }
-}
+constexpr std::optional<T> TryGetEnumUnknownValueImpl(T);
template <
class T,
- bool = IsEnumDomainSizeKnown<T>()
+ bool DomainSizeKnown = requires{ TEnumTraitsImpl<T>::DomainSize; }
>
struct TEnumTraitsWithKnownDomain
{ };
@@ -62,7 +55,7 @@ struct TEnumTraits
};
template <class T>
-struct TEnumTraitsWithKnownDomain<T, true>
+struct TEnumTraitsWithKnownDomain<T, /*DomainSizeKnown*/ true>
{
static constexpr int GetDomainSize();
@@ -91,6 +84,7 @@ struct TEnumTraits<T, true>
static TStringBuf GetTypeName();
+ static constexpr std::optional<T> TryGetUnknownValue();
static std::optional<TStringBuf> FindLiteralByValue(T value);
static std::optional<T> FindValueByLiteral(TStringBuf literal);
@@ -102,7 +96,7 @@ struct TEnumTraits<T, true>
//! Defines a smart enumeration with a specific underlying type.
/*!
- * \param enumType Enumeration enumType.
+ * \param enumType Enumeration type.
* \param seq Enumeration domain encoded as a <em>sequence</em>.
* \param underlyingType Underlying type.
*/
@@ -127,7 +121,7 @@ struct TEnumTraits<T, true>
//! Defines a smart enumeration with a specific underlying type.
/*!
- * \param enumType Enumeration enumType.
+ * \param enumType Enumeration type.
* \param seq Enumeration domain encoded as a <em>sequence</em>.
* \param underlyingType Underlying type.
*/
@@ -142,7 +136,7 @@ struct TEnumTraits<T, true>
//! Defines a smart enumeration with a specific underlying type.
//! Duplicate enumeration values are allowed.
/*!
- * \param enumType Enumeration enumType.
+ * \param enumType Enumeration type.
* \param seq Enumeration domain encoded as a <em>sequence</em>.
* \param underlyingType Underlying type.
*/
@@ -155,7 +149,7 @@ struct TEnumTraits<T, true>
//! Defines a smart enumeration with the default |unsigned int| underlying type.
/*!
- * \param enumType Enumeration enumType.
+ * \param enumType Enumeration type.
* \param seq Enumeration domain encoded as a <em>sequence</em>.
*/
#define DEFINE_BIT_ENUM(enumType, seq) \
@@ -163,7 +157,7 @@ struct TEnumTraits<T, true>
//! Defines a smart enumeration with a specific underlying type and IsStringSerializable attribute.
/*!
- * \param enumType Enumeration enumType.
+ * \param enumType Enumeration type.
* \param seq Enumeration domain encoded as a <em>sequence</em>.
* \param underlyingType Underlying type.
*/
@@ -186,6 +180,18 @@ struct TEnumTraits<T, true>
#define DEFINE_STRING_SERIALIZABLE_ENUM(enumType, seq) \
DEFINE_STRING_SERIALIZABLE_ENUM_WITH_UNDERLYING_TYPE(enumType, int, seq)
+//! When enum from another representation (e.g. string or protobuf integer),
+//! instructs the parser to treat undeclared values as |unknownValue|.
+/*!
+ * \param enumType Enumeration type.
+ * \param unknownValue A sentinel value of #enumType.
+ */
+#define DEFINE_ENUM_UNKNOWN_VALUE(enumType, unknownValue) \
+ [[maybe_unused]] constexpr std::optional<enumType> TryGetEnumUnknownValueImpl(enumType) \
+ { \
+ return enumType::unknownValue; \
+ }
+
////////////////////////////////////////////////////////////////////////////////
//! Returns |true| iff the enumeration value is not bitwise zero.
diff --git a/library/cpp/yt/misc/unittests/enum_ut.cpp b/library/cpp/yt/misc/unittests/enum_ut.cpp
index 63b8666ae1..938ab11581 100644
--- a/library/cpp/yt/misc/unittests/enum_ut.cpp
+++ b/library/cpp/yt/misc/unittests/enum_ut.cpp
@@ -50,6 +50,13 @@ DEFINE_ENUM_WITH_UNDERLYING_TYPE(ECardinal, char,
((South) (3))
);
+DEFINE_ENUM(EWithUnknown,
+ (First)
+ (Second)
+ (Unknown)
+);
+DEFINE_ENUM_UNKNOWN_VALUE(EWithUnknown, Unknown);
+
////////////////////////////////////////////////////////////////////////////////
template <class T, size_t N>
@@ -280,6 +287,12 @@ TEST(TEnumTest, Cast)
}
}
+TEST(TEnumTest, UnknownValue)
+{
+ EXPECT_EQ(TEnumTraits<EColor>::TryGetUnknownValue(), std::nullopt);
+ EXPECT_EQ(TEnumTraits<EWithUnknown>::TryGetUnknownValue(), EWithUnknown::Unknown);
+}
+
////////////////////////////////////////////////////////////////////////////////
} // namespace
diff --git a/library/cpp/yt/string/enum-inl.h b/library/cpp/yt/string/enum-inl.h
index 41f7197d15..84b0941d15 100644
--- a/library/cpp/yt/string/enum-inl.h
+++ b/library/cpp/yt/string/enum-inl.h
@@ -5,6 +5,8 @@
#endif
#include "format.h"
+#include "string.h"
+#include "string_builder.h"
#include <library/cpp/yt/exception/exception.h>
@@ -23,110 +25,106 @@ void ThrowMalformedEnumValueException(
TStringBuf value);
void FormatUnknownEnumValue(
- TStringBuilderBase* builder,
+ auto* builder,
TStringBuf name,
- i64 value);
+ auto value)
+{
+ builder->AppendFormat("%v::unknown-%v", name, ToUnderlying(value));
+}
} // namespace NDetail
template <class T>
-std::optional<T> TryParseEnum(TStringBuf value)
+std::optional<T> TryParseEnum(TStringBuf str, bool enableUnknown)
{
- auto tryFromString = [] (TStringBuf value) -> std::optional<T> {
- if (auto decodedValue = TryDecodeEnumValue(value)) {
- auto enumValue = TEnumTraits<T>::FindValueByLiteral(*decodedValue);
- return enumValue ? enumValue : TEnumTraits<T>::FindValueByLiteral(value);
- }
+ auto tryParseToken = [&] (TStringBuf token) -> std::optional<T> {
+ if (auto optionalValue = TEnumTraits<T>::FindValueByLiteral(token)) {
+ return *optionalValue;
- auto reportError = [value] () {
- throw TSimpleException(Format("Enum value %Qv is neither in a proper underscore case nor in a format \"%v(123)\"",
- value,
- TEnumTraits<T>::GetTypeName()));
- };
-
- TStringBuf typeName;
- auto isTypeNameCorrect = value.NextTok('(', typeName) && typeName == TEnumTraits<T>::GetTypeName();
- if (!isTypeNameCorrect) {
- reportError();
}
- TStringBuf enumValue;
- std::underlying_type_t<T> underlyingValue = 0;
- auto isEnumValueCorrect = value.NextTok(')', enumValue) && TryFromString(enumValue, underlyingValue);
- if (!isEnumValueCorrect) {
- reportError();
+ if (auto optionalDecodedValue = TryDecodeEnumValue(token)) {
+ if (auto optionalValue = TEnumTraits<T>::FindValueByLiteral(*optionalDecodedValue)) {
+ return *optionalValue;
+ }
}
- auto isParsingComplete = value.empty();
- if (!isParsingComplete) {
- reportError();
+ if (enableUnknown) {
+ if constexpr (constexpr auto optionalUnknownValue = TEnumTraits<T>::TryGetUnknownValue()) {
+ return *optionalUnknownValue;
+ }
}
- return static_cast<T>(underlyingValue);
+ return std::nullopt;
};
if constexpr (TEnumTraits<T>::IsBitEnum) {
T result{};
TStringBuf token;
- while (value.NextTok('|', token)) {
- if (auto scalar = tryFromString(StripString(token))) {
- result |= *scalar;
+ while (str.NextTok('|', token)) {
+ if (auto optionalValue = tryParseToken(StripString(token))) {
+ result |= *optionalValue;
} else {
return {};
}
}
return result;
} else {
- return tryFromString(value);
+ return tryParseToken(str);
}
}
template <class T>
-T ParseEnum(TStringBuf value)
+T ParseEnum(TStringBuf str)
{
- if (auto optionalResult = TryParseEnum<T>(value)) {
+ if (auto optionalResult = TryParseEnum<T>(str, /*enableUnkown*/ true)) {
return *optionalResult;
}
- NYT::NDetail::ThrowMalformedEnumValueException(TEnumTraits<T>::GetTypeName(), value);
+ NYT::NDetail::ThrowMalformedEnumValueException(TEnumTraits<T>::GetTypeName(), str);
}
template <class T>
void FormatEnum(TStringBuilderBase* builder, T value, bool lowerCase)
{
- auto formatScalarValue = [builder, lowerCase] (T value) {
- auto optionalLiteral = TEnumTraits<T>::FindLiteralByValue(value);
- if (!optionalLiteral) {
- NYT::NDetail::FormatUnknownEnumValue(
- builder,
- TEnumTraits<T>::GetTypeName(),
- ToUnderlying(value));
- return;
- }
-
+ auto formatLiteral = [&] (auto* builder, TStringBuf literal) {
if (lowerCase) {
- CamelCaseToUnderscoreCase(builder, *optionalLiteral);
+ CamelCaseToUnderscoreCase(builder, literal);
} else {
- builder->AppendString(*optionalLiteral);
+ builder->AppendString(literal);
}
};
if constexpr (TEnumTraits<T>::IsBitEnum) {
- if (TEnumTraits<T>::FindLiteralByValue(value)) {
- formatScalarValue(value);
+ if (None(value)) {
+ // Avoid empty string if possible.
+ if (auto optionalLiteral = TEnumTraits<T>::FindLiteralByValue(value)) {
+ formatLiteral(builder, *optionalLiteral);
+ }
return;
}
- auto first = true;
- for (auto scalarValue : TEnumTraits<T>::GetDomainValues()) {
- if (Any(value & scalarValue)) {
- if (!first) {
- builder->AppendString(TStringBuf(" | "));
- }
- first = false;
- formatScalarValue(scalarValue);
+
+ TDelimitedStringBuilderWrapper delimitedBuilder(builder, " | ");
+
+ T printedValue{};
+ for (auto currentValue : TEnumTraits<T>::GetDomainValues()) {
+ // Check if currentValue is viable and non-redunant.
+ if ((value & currentValue) == currentValue && (printedValue | currentValue) != printedValue) {
+ formatLiteral(&delimitedBuilder, *TEnumTraits<T>::FindLiteralByValue(currentValue));
+ printedValue |= currentValue;
}
}
+
+ // Handle the remainder.
+ if (printedValue != value) {
+ NYT::NDetail::FormatUnknownEnumValue(&delimitedBuilder, TEnumTraits<T>::GetTypeName(), value & ~printedValue);
+ }
} else {
- formatScalarValue(value);
+ if (auto optionalLiteral = TEnumTraits<T>::FindLiteralByValue(value)) {
+ formatLiteral(builder, *optionalLiteral);
+ return;
+ }
+
+ NYT::NDetail::FormatUnknownEnumValue(builder, TEnumTraits<T>::GetTypeName(), value);
}
}
diff --git a/library/cpp/yt/string/enum.cpp b/library/cpp/yt/string/enum.cpp
index e61b813fd2..935c3e6e3e 100644
--- a/library/cpp/yt/string/enum.cpp
+++ b/library/cpp/yt/string/enum.cpp
@@ -6,13 +6,22 @@ namespace NYT {
////////////////////////////////////////////////////////////////////////////////
-template <bool failOnError>
+namespace NDetail {
+
+void ThrowMalformedEnumValueException(TStringBuf typeName, TStringBuf value)
+{
+ throw TSimpleException(Format("Error parsing %v value %Qv",
+ typeName,
+ value));
+}
+
+template <bool ThrowOnError>
std::optional<TString> DecodeEnumValueImpl(TStringBuf value)
{
auto camelValue = UnderscoreCaseToCamelCase(value);
auto underscoreValue = CamelCaseToUnderscoreCase(camelValue);
if (value != underscoreValue) {
- if constexpr (failOnError) {
+ if constexpr (ThrowOnError) {
throw TSimpleException(Format("Enum value %Qv is not in a proper underscore case; did you mean %Qv?",
value,
underscoreValue));
@@ -23,14 +32,16 @@ std::optional<TString> DecodeEnumValueImpl(TStringBuf value)
return camelValue;
}
+} // namespace NDetail
+
std::optional<TString> TryDecodeEnumValue(TStringBuf value)
{
- return DecodeEnumValueImpl<false>(value);
+ return NDetail::DecodeEnumValueImpl<false>(value);
}
TString DecodeEnumValue(TStringBuf value)
{
- auto decodedValue = DecodeEnumValueImpl<true>(value);
+ auto decodedValue = NDetail::DecodeEnumValueImpl<true>(value);
YT_VERIFY(decodedValue);
return *decodedValue;
}
@@ -40,22 +51,6 @@ TString EncodeEnumValue(TStringBuf value)
return CamelCaseToUnderscoreCase(value);
}
-namespace NDetail {
-
-void ThrowMalformedEnumValueException(TStringBuf typeName, TStringBuf value)
-{
- throw TSimpleException(Format("Error parsing %v value %Qv",
- typeName,
- value));
-}
-
-void FormatUnknownEnumValue(TStringBuilderBase* builder, TStringBuf name, i64 value)
-{
- builder->AppendFormat("%v(%v)", name, value);
-}
-
-} // namespace NDetail
-
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT
diff --git a/library/cpp/yt/string/enum.h b/library/cpp/yt/string/enum.h
index 792e09402d..a0be527583 100644
--- a/library/cpp/yt/string/enum.h
+++ b/library/cpp/yt/string/enum.h
@@ -15,10 +15,10 @@ TString DecodeEnumValue(TStringBuf value);
TString EncodeEnumValue(TStringBuf value);
template <class T>
-std::optional<T> TryParseEnum(TStringBuf value);
+std::optional<T> TryParseEnum(TStringBuf str, bool enableUnknown = false);
template <class T>
-T ParseEnum(TStringBuf value);
+T ParseEnum(TStringBuf str);
template <class T>
void FormatEnum(TStringBuilderBase* builder, T value, bool lowerCase);
diff --git a/library/cpp/yt/string/unittests/enum_ut.cpp b/library/cpp/yt/string/unittests/enum_ut.cpp
index be5387151a..39dbdfd207 100644
--- a/library/cpp/yt/string/unittests/enum_ut.cpp
+++ b/library/cpp/yt/string/unittests/enum_ut.cpp
@@ -27,13 +27,39 @@ DEFINE_BIT_ENUM(ELangs,
((Rust) (0x04))
((Python) (0x08))
((JavaScript) (0x10))
+ ((CppGo) (0x03))
+ ((All) (0x1f))
);
+DEFINE_BIT_ENUM(ELangsWithUnknown,
+ ((None) (0x00))
+ ((Cpp) (0x01))
+ ((Go) (0x02))
+ ((Rust) (0x04))
+ ((Python) (0x08))
+ ((JavaScript) (0x10))
+ ((CppGo) (0x03))
+ ((All) (0x1f))
+ ((Unknown) (0x20))
+);
+DEFINE_ENUM_UNKNOWN_VALUE(ELangsWithUnknown, Unknown);
+
DEFINE_ENUM(ECustomDomainName,
((A) (1) ("value_a"))
((B) (2) ("value_b"))
);
+DEFINE_ENUM(EColorWithUnknown,
+ (Red)
+ (Green)
+ (Unknown)
+);
+DEFINE_ENUM_UNKNOWN_VALUE(EColorWithUnknown, Unknown);
+
+DEFINE_BIT_ENUM(EBitEnumWithoutNone,
+ ((Some)(1))
+);
+
TEST(TFormatTest, Enum)
{
EXPECT_EQ("Red", Format("%v", EColor::Red));
@@ -42,7 +68,8 @@ TEST(TFormatTest, Enum)
EXPECT_EQ("BlackAndWhite", Format("%v", EColor::BlackAndWhite));
EXPECT_EQ("black_and_white", Format("%lv", EColor::BlackAndWhite));
- EXPECT_EQ("EColor(100)", Format("%v", EColor(100)));
+ EXPECT_EQ("EColor::unknown-100", Format("%v", EColor(100)));
+ EXPECT_EQ("Cpp | ELangs::unknown-32", Format("%v", ELangs(0x21)));
EXPECT_EQ("JavaScript", Format("%v", ELangs::JavaScript));
EXPECT_EQ("java_script", Format("%lv", ELangs::JavaScript));
@@ -50,6 +77,8 @@ TEST(TFormatTest, Enum)
EXPECT_EQ("None", Format("%v", ELangs::None));
EXPECT_EQ("none", Format("%lv", ELangs::None));
+ EXPECT_EQ("", Format("%v", EBitEnumWithoutNone()));
+
EXPECT_EQ("Cpp | Go", Format("%v", ELangs::Cpp | ELangs::Go));
EXPECT_EQ("cpp | go", Format("%lv", ELangs::Cpp | ELangs::Go));
@@ -64,6 +93,19 @@ TEST(TFormatEnumTest, FormatEnumWithCustomDomainName)
EXPECT_EQ("value_b", FormatEnum(ECustomDomainName::B));
}
+TEST(TParseEnumTest, ParseUnknown)
+{
+ EXPECT_EQ(std::nullopt, TryParseEnum<EColor>("yellow"));
+ EXPECT_THROW(ParseEnum<EColor>("yellow"), TSimpleException);
+ EXPECT_EQ(std::nullopt, TryParseEnum<EColorWithUnknown>("yellow"));
+ EXPECT_EQ(EColorWithUnknown::Unknown, TryParseEnum<EColorWithUnknown>("yellow", /*enableUnknown*/ true));
+ EXPECT_EQ(EColorWithUnknown::Unknown, ParseEnum<EColorWithUnknown>("yellow"));
+ EXPECT_EQ(std::nullopt, TryParseEnum<ELangs>("cpp | haskell"));
+ EXPECT_THROW(ParseEnum<ELangs>("cpp | haskell"), TSimpleException);
+ EXPECT_EQ(ELangsWithUnknown::Cpp | ELangsWithUnknown::Unknown, TryParseEnum<ELangsWithUnknown>("cpp | haskell", /*enableUnknown*/ true));
+ EXPECT_EQ(ELangsWithUnknown::Cpp | ELangsWithUnknown::Unknown, ParseEnum<ELangsWithUnknown>("cpp | haskell"));
+}
+
TEST(TParseEnumTest, ParseEnumWithCustomDomainName)
{
EXPECT_EQ(ECustomDomainName::A, TryParseEnum<ECustomDomainName>("value_a"));
@@ -77,7 +119,7 @@ TEST(TParseEnumTest, ParseBitEnum)
EXPECT_EQ(ELangs::Cpp, TryParseEnum<ELangs>("cpp"));
EXPECT_EQ(ELangs::Cpp | ELangs::Rust, TryParseEnum<ELangs>("cpp|rust"));
EXPECT_EQ(ELangs::Cpp | ELangs::Rust, TryParseEnum<ELangs>("cpp | rust"));
- EXPECT_EQ(std::nullopt, TryParseEnum<ELangs>("unk | rust"));
+ EXPECT_EQ(std::nullopt, TryParseEnum<ELangs>("haskell | rust"));
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/yt/yt/core/misc/unittests/string_ut.cpp b/yt/yt/core/misc/unittests/string_ut.cpp
deleted file mode 100644
index b2ffbf4218..0000000000
--- a/yt/yt/core/misc/unittests/string_ut.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-#include <yt/yt/core/test_framework/framework.h>
-
-#include <library/cpp/yt/string/enum.h>
-
-namespace NYT {
-namespace {
-
-////////////////////////////////////////////////////////////////////////////////
-
-DEFINE_ENUM(EColor,
- (Red)
- (BlackAndWhite)
-);
-
-DEFINE_BIT_ENUM(ELangs,
- ((None) (0x00))
- ((Cpp) (0x01))
- ((Go) (0x02))
- ((Rust) (0x04))
- ((Python) (0x08))
- ((JavaScript) (0x10))
-);
-
-TEST(TStringTest, Enum)
-{
- EXPECT_EQ("red", FormatEnum(EColor::Red));
- EXPECT_EQ(ParseEnum<EColor>("red"), EColor::Red);
-
- EXPECT_EQ("black_and_white", FormatEnum(EColor::BlackAndWhite));
- EXPECT_EQ(ParseEnum<EColor>("black_and_white"), EColor::BlackAndWhite);
-
- EXPECT_EQ("EColor(100)", FormatEnum(EColor(100)));
-
- EXPECT_EQ("java_script", FormatEnum(ELangs::JavaScript));
- EXPECT_EQ(ParseEnum<ELangs>("java_script"), ELangs::JavaScript);
-
- EXPECT_EQ("none", FormatEnum(ELangs::None));
- EXPECT_EQ(ParseEnum<ELangs>("none"), ELangs::None);
-
- EXPECT_EQ("cpp | go", FormatEnum(ELangs::Cpp | ELangs::Go));
- EXPECT_EQ(ParseEnum<ELangs>("cpp | go"), ELangs::Cpp | ELangs::Go);
-
- auto four = ELangs::Cpp | ELangs::Go | ELangs::Python | ELangs::JavaScript;
- EXPECT_EQ("cpp | go | python | java_script", FormatEnum(four));
- EXPECT_EQ(ParseEnum<ELangs>("cpp | go | python | java_script"), four);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
-} // namespace
-} // namespace NYT
-
diff --git a/yt/yt/core/misc/unittests/ya.make b/yt/yt/core/misc/unittests/ya.make
index 8d1e1af3f9..f0e7235cf3 100644
--- a/yt/yt/core/misc/unittests/ya.make
+++ b/yt/yt/core/misc/unittests/ya.make
@@ -68,7 +68,6 @@ SRCS(
spsc_queue_ut.cpp
statistic_path_ut.cpp
statistics_ut.cpp
- string_ut.cpp
sync_expiring_cache_ut.cpp
time_formula_ut.cpp
tls_destructor_ut.cpp
diff --git a/yt/yt/core/ytree/unittests/serialize_ut.cpp b/yt/yt/core/ytree/unittests/serialize_ut.cpp
index 63bf71b0d2..73d7acf20b 100644
--- a/yt/yt/core/ytree/unittests/serialize_ut.cpp
+++ b/yt/yt/core/ytree/unittests/serialize_ut.cpp
@@ -385,7 +385,7 @@ TEST(TSerializationTest, VectorOfTuple)
std::vector<std::tuple<int, TString, size_t>> original{
std::tuple<int, TString, size_t>(43, "First", 343U),
std::tuple<int, TString, size_t>(0, "Second", 7U),
- std::tuple<int, TString, size_t>(2323, "Third", 9U)
+ std::tuple<int, TString, size_t>(2323, "Third", 9U),
};
TestSerializationDeserialization(original);
@@ -398,7 +398,7 @@ TEST(TSerializationTest, MapOnArray)
{"1", {{2112U, 4343U, 5445U}}},
{"22", {{54654U, 93U, 5U}}},
{"333", {{7U, 93U, 9U}}},
- {"rel", {{233U, 9763U, 0U}}}
+ {"rel", {{233U, 9763U, 0U}}},
};
TestSerializationDeserialization(original);
TestSerializationDeserialization(original, EYsonType::MapFragment);
@@ -406,20 +406,14 @@ TEST(TSerializationTest, MapOnArray)
TEST(TSerializationTest, Enum)
{
- for (const auto original : TEnumTraits<ETestEnum>::GetDomainValues()) {
+ for (auto original : TEnumTraits<ETestEnum>::GetDomainValues()) {
TestSerializationDeserialization(original);
}
}
-TEST(TSerializationTest, EnumUnknownValue)
-{
- auto unknownValue = static_cast<ETestEnum>(ToUnderlying(TEnumTraits<ETestEnum>::GetMaxValue()) + 1);
- TestSerializationDeserialization(unknownValue);
-}
-
TEST(TSerializationTest, BitEnum)
{
- for (const auto original : TEnumTraits<ETestBitEnum>::GetDomainValues()) {
+ for (auto original : TEnumTraits<ETestBitEnum>::GetDomainValues()) {
TestSerializationDeserialization(original);
}
TestSerializationDeserialization(ETestBitEnum::Green | ETestBitEnum::Red);
@@ -428,7 +422,7 @@ TEST(TSerializationTest, BitEnum)
TEST(TSerializationTest, SerializableArcadiaEnum)
{
- for (const auto original : GetEnumAllValues<ESerializableArcadiaEnum>()) {
+ for (auto original : GetEnumAllValues<ESerializableArcadiaEnum>()) {
TestSerializationDeserialization(original);
}
}