| 9 | |
| 10 | Y_UNIT_TEST_SUITE(TestSerializedEnum) { |
| 11 | Y_UNIT_TEST(RepresentationTypes) { |
| 12 | using namespace NEnumSerializationRuntime::NDetail; |
| 13 | |
| 14 | static_assert(TIsPromotable<int, int>::value, "int -> int"); |
| 15 | static_assert(TIsPromotable<char, int>::value, "char -> int"); |
| 16 | static_assert(TIsPromotable<unsigned short, unsigned long>::value, "unsigned short -> unsigned long"); |
| 17 | static_assert(TIsPromotable<i64, long long>::value, "i64 -> long long"); |
| 18 | static_assert(!TIsPromotable<ui64, ui8>::value, "ui64 -> ui8"); |
| 19 | static_assert(!TIsPromotable<i64, short>::value, "i64 -> short"); |
| 20 | |
| 21 | enum EEmpty { |
| 22 | }; |
| 23 | UNIT_ASSERT_C((TTypeList<int, unsigned>::THave<typename TSelectEnumRepresentationType<EEmpty>::TType>::value), "empty enum using signed or unsigned integer underlying type"); |
| 24 | |
| 25 | using TRepresentationTypeList = TTypeList<int, unsigned, long long, unsigned long long>; |
| 26 | |
| 27 | enum class ERegular { |
| 28 | One = 1, |
| 29 | Two = 2, |
| 30 | Five = 5, |
| 31 | }; |
| 32 | UNIT_ASSERT(TRepresentationTypeList::THave<typename TSelectEnumRepresentationType<ERegular>::TType>::value); |
| 33 | |
| 34 | enum class ESmall: unsigned char { |
| 35 | Six = 6, |
| 36 | }; |
| 37 | UNIT_ASSERT(TRepresentationTypeList::THave<typename TSelectEnumRepresentationType<ESmall>::TType>::value); |
| 38 | |
| 39 | enum class EHugeUnsigned: ui64 { |
| 40 | Value = 0, |
| 41 | }; |
| 42 | UNIT_ASSERT(TRepresentationTypeList::THave<typename TSelectEnumRepresentationType<EHugeUnsigned>::TType>::value); |
| 43 | |
| 44 | enum class EHugeSigned: i64 { |
| 45 | Value = -2, |
| 46 | }; |
| 47 | UNIT_ASSERT(TRepresentationTypeList::THave<typename TSelectEnumRepresentationType<EHugeSigned>::TType>::value); |
| 48 | } |
| 49 | |
| 50 | Y_UNIT_TEST(MappedArrayView) { |
| 51 | enum class ETestEnum: signed char { |