pitrou commented on code in PR #45370:
URL: https://github.com/apache/arrow/pull/45370#discussion_r1941271042


##########
cpp/src/arrow/scalar_test.cc:
##########
@@ -866,6 +866,9 @@ TEST(TestTimeScalars, Basics) {
     ASSERT_TRUE(first->Equals(*MakeScalar(ty, 5).ValueOrDie()));
     ASSERT_TRUE(last->Equals(*MakeScalar(ty, 42).ValueOrDie()));
     ASSERT_FALSE(last->Equals(*MakeScalar("string")));
+
+    ASSERT_OK_AND_ASSIGN(auto casted, first->CastTo(ty));
+    ASSERT_TRUE(casted->Equals(*first));

Review Comment:
   Can we create a generic test for identity cast instead? Something like:
   ```c++
   TEST(TestIdentityCast, AllTypes) {
     RandomArrayGenerator rng(/*seed=*/42);
     for (auto type : {...}) {
       ASSERT_OK_AND_ASSIGN(
           auto scalar, rng.ArrayOf(type, /*size=*/1).GetScalar(0));
       ASSERT_OK_AND_ASSIGN(auto casted, scalar->CastTo(ty));
       ASSERT_TRUE(casted->Equals(*scalar));
     }
   }
   ```



-- 
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