benibus commented on code in PR #499:
URL: https://github.com/apache/arrow-nanoarrow/pull/499#discussion_r1621172527


##########
src/nanoarrow/utils_test.cc:
##########
@@ -543,6 +543,36 @@ TEST(DecimalTest, DecimalRoundtripBitshiftTest) {
   ArrowBufferReset(&buffer);
 }
 
+// test case adapted from
+// https://github.com/apache/arrow/blob/main/go/arrow/float16/float16_test.go
+TEST(HalfFloatTest, FloatToHalfFloat) {

Review Comment:
   We should specifically test that NaNs are preserved as well. It's a simple 
check, fortunately: 
https://github.com/apache/arrow/blob/6800be9331d88024bf550c77865a06c592a22699/go/arrow/float16/float16.go#L176



##########
src/nanoarrow/utils_test.cc:
##########
@@ -543,6 +543,36 @@ TEST(DecimalTest, DecimalRoundtripBitshiftTest) {
   ArrowBufferReset(&buffer);
 }
 
+// test case adapted from
+// https://github.com/apache/arrow/blob/main/go/arrow/float16/float16_test.go
+TEST(HalfFloatTest, FloatToHalfFloat) {
+  uint16_t cases_bits[] = {
+    0x3c00,
+    0x4000,
+    0xc000,
+    0x0000,
+    0x5b8f,
+    0xdb8f,
+    0x48c8,
+    0xc8c8,
+  };
+  float cases_float[] = {

Review Comment:
   A few more test cases that would be easy to add here:
   - `-0` -> `0x8000`
   - `+inf` -> `0x7c00`
   - `-inf` -> `0xfc00`



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