lidavidm commented on a change in pull request #10691:
URL: https://github.com/apache/arrow/pull/10691#discussion_r667667208



##########
File path: cpp/src/arrow/util/reflection_test.cc
##########
@@ -220,5 +221,63 @@ TEST(Reflection, EnumTraits) {
   static_assert(std::is_same<EnumTraits<PersonType>::Type, Int8Type>::value, 
"");
 }
 
+TEST(Reflection, CompileTimeStringOps) {
+  static_assert(CaseInsensitiveEquals("a", "a"), "");
+  static_assert(CaseInsensitiveEquals("Ab", "ab"), "");
+  static_assert(CaseInsensitiveEquals("Ab ", "ab", 2), "");
+  static_assert(CaseInsensitiveEquals(util::string_view{"Ab ", 2}, "ab"), "");
+
+  static_assert(CaseInsensitiveEquals(SkipWhitespace("  a"), "a"), "");
+  static_assert(CaseInsensitiveEquals(SkipWhitespace("a  b"), "a  b"), "");
+
+  static_assert(CaseInsensitiveEquals(SkipNonWhitespace("  a"), "  a"), "");
+  static_assert(CaseInsensitiveEquals(SkipNonWhitespace("a  b"), "  b"), "");
+
+  static_assert(TokenSize("aba ddf") == 3, "");
+
+  static_assert(NextTokenStart("aba ddf dfas", 4) == 8, "");
+}
+
+struct Color : EnumType<Color> {
+  using EnumType<Color>::EnumType;
+  static constexpr const char* kValues = R"(red green blue)";
+};
+
+TEST(Reflection, EnumType) {
+  static_assert(Color::size() == 3, "");
+
+  static_assert(Color("red").index == 0, "");
+  static_assert(*Color("GREEN") == 1, "");
+  static_assert(Color("Blue") == Color(2), "");
+
+  EXPECT_EQ(Color("red").ToString(), "red");
+  EXPECT_EQ(Color("GREEN").ToString(), "green");
+  EXPECT_EQ(Color("Blue").ToString(), "blue");
+
+  static_assert(Color("GREEN") == Color("Green"), "");
+  static_assert(Color("GREEN") == Color(1), "");
+  static_assert(Color("GREEN") != Color(), "");
+
+  static_assert(!Color("chartreuse"), "");
+  static_assert(Color("violet") == Color(), "");
+  static_assert(Color(-1) == Color(), "");
+  static_assert(Color(-29) == Color(), "");
+  static_assert(Color(12334) == Color(), "");
+
+  for (util::string_view repr : {"Red", "orange", "BLUE"}) {
+    switch (*Color(repr)) {
+      case* Color("blue"):
+        EXPECT_EQ(repr, "BLUE");
+        break;
+      case* Color("red"):
+        EXPECT_EQ(repr, "Red");
+        break;
+      default:

Review comment:
       Oh I guess no by definition since we're switching on int here.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to