lriggs commented on code in PR #51266:
URL: https://github.com/apache/arrow/pull/51266#discussion_r4008360130


##########
cpp/src/arrow/scalar_test.cc:
##########
@@ -973,6 +973,39 @@ TEST(TestDateScalars, MakeScalar) {
                     Date64Scalar(-188171LL * 24 * 60 * 60 * 1000));
 }
 
+TEST(TestDateScalars, CastTo) {

Review Comment:
   Can you add a few negative value cases? There might be a round/truncation 
issue, for example:
   
     // 1969-12-31T12:00:00Z -- mid-day, pre-epoch. Truncation toward zero 
lands on
     // 1970-01-01 instead of 1969-12-31.
     {
       const auto ts = TimestampScalar(-kMillisecondsInDay / 2, 
timestamp(TimeUnit::MILLI));
       ASSERT_OK_AND_ASSIGN(auto d32, ts.CastTo(date32()));
       ASSERT_OK_AND_ASSIGN(auto d64, ts.CastTo(date64()));
       EXPECT_EQ(*d32, Date32Scalar(-1));                      // currently 0
       EXPECT_EQ(*d64, Date64Scalar(-kMillisecondsInDay));     // currently 0
     }



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