alinaliBQ commented on code in PR #47017:
URL: https://github.com/apache/arrow/pull/47017#discussion_r2226232883


##########
cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/date_array_accessor_test.cc:
##########
@@ -60,19 +64,22 @@ TEST(DateArrayAccessor, Test_Date32Array_CDataType_DATE) {
 
   for (size_t i = 0; i < values.size(); ++i) {
     ASSERT_EQ(sizeof(DATE_STRUCT), strlen_buffer[i]);
-    tm date{};
 
-    int64_t converted_time = values[i] * 86400;
-    GetTimeForSecondsSinceEpoch(date, converted_time);
-    ASSERT_EQ((date.tm_year + 1900), buffer[i].year);
-    ASSERT_EQ(date.tm_mon + 1, buffer[i].month);
-    ASSERT_EQ(date.tm_mday, buffer[i].day);
+    ASSERT_EQ(expected[i].year, buffer[i].year);
+    ASSERT_EQ(expected[i].month, buffer[i].month);
+    ASSERT_EQ(expected[i].day, buffer[i].day);
   }
 }
 
 TEST(DateArrayAccessor, Test_Date64Array_CDataType_DATE) {
-  std::vector<int64_t> values = {86400000,  172800000, 259200000, 
1649793238110,
-                                 345600000, 432000000, 518400000};
+  std::vector<int64_t> values = {86400000,  172800000,      259200000, 
1649793238110,
+                                 0,         345600000,      432000000, 
518400000,
+                                 -86400000, -17987443200000};
+  std::vector<tagDATE_STRUCT> expected = {
+      /* year(16), month(u16), day(u16) */
+      {1970, 1, 2}, {1970, 1, 3}, {1970, 1, 4}, {2022, 4, 12},  {1970, 1, 1},
+      {1970, 1, 5}, {1970, 1, 6}, {1970, 1, 7}, {1969, 12, 31}, {1400, 1, 1},
+  };

Review Comment:
   Suggestion: could we add a test for a date with year before 1400? E.g., 
{1399, 2, 14}



##########
cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/date_array_accessor_test.cc:
##########
@@ -38,7 +38,11 @@ using arrow::ArrayFromVector;
 using odbcabstraction::GetTimeForSecondsSinceEpoch;
 
 TEST(DateArrayAccessor, Test_Date32Array_CDataType_DATE) {
-  std::vector<int32_t> values = {7589, 12320, 18980, 19095};
+  std::vector<int32_t> values = {7589, 12320, 18980, 19095, -1, 0};
+  std::vector<tagDATE_STRUCT> expected = {
+      {1990, 10, 12}, {2003, 9, 25},  {2021, 12, 19},
+      {2022, 4, 13},  {1969, 12, 31}, {1970, 1, 1},
+  };

Review Comment:
   Suggestion: could we add a test for a date with year before 1400? E.g., 
`{1399, 2, 14}`



-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to