Browse Source

Intermediate changes

robot-piglet 11 months ago
parent
commit
3ea83364ce

+ 8 - 0
tools/enum_parser/parse_enum/ut/enums.cpp

@@ -8,6 +8,7 @@
 #include <util/generic/serialized_enum.h>
 #include <library/cpp/testing/unittest/registar.h>
 
+#include <util/generic/algorithm.h>
 #include <util/generic/ptr.h>
 #include <util/generic/singleton.h>
 
@@ -197,4 +198,11 @@ Y_UNIT_TEST_SUITE(TEnumGeneratorTest) {
     Y_UNIT_TEST(EnumSerializerDestructionPriority) {
         Singleton<TEnumSerializationInitializerHolder>()->Init();
     }
+
+    Y_UNIT_TEST(ValuesSortTest) {
+        const auto& allValues = GetEnumAllValues<ENontrivialValues>();
+        UNIT_ASSERT_VALUES_EQUAL(allValues.size(), 4u);
+        UNIT_ASSERT(IsSorted(allValues.begin(), allValues.end()));
+    }
+
 };

+ 15 - 0
tools/enum_parser/parse_enum/ut/enums_with_header.h

@@ -6,3 +6,18 @@ enum EWithHeader {
     HThree,
 };
 
+
+constexpr unsigned EvalValue(unsigned r, unsigned d) {
+    while (r >= 50) {
+        r *= d;
+    }
+    return r;
+}
+
+//  enumeration with values that depend on the preprocessor, architecture and constexpr function evaluation
+enum class ENontrivialValues {
+    A = __LINE__,
+    B = EvalValue(1522858842, 13),
+    C,
+    D = sizeof(int*[A][C]),
+};