Skip to content

Commit ac78adf

Browse files
committed
Update comment in float16 decoding unit tests
1 parent 48850b2 commit ac78adf

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

decode_test.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ type unmarshalTest struct {
4949
wrongTypes []reflect.Type
5050
}
5151

52-
// CBOR test data are from https://tools.ietf.org/html/rfc7049#appendix-A.
5352
var unmarshalTests = []unmarshalTest{
53+
// CBOR test data are from https://tools.ietf.org/html/rfc7049#appendix-A.
5454
// positive integer
5555
{
5656
hexDecode("00"),
@@ -473,8 +473,11 @@ type unmarshalFloatTest struct {
473473
equalityThreshold float64 // Not used for +inf, -inf, and NaN.
474474
}
475475

476-
// CBOR test data are from https://tools.ietf.org/html/rfc7049#appendix-A.
476+
// unmarshalFloatTests includes test values for float16, float32, and float64.
477+
// Note: the function for float16 to float32 conversion was tested with all
478+
// 65536 values, which is too many to include here.
477479
var unmarshalFloatTests = []unmarshalFloatTest{
480+
// CBOR test data are from https://tools.ietf.org/html/rfc7049#appendix-A.
478481
// float16
479482
{
480483
hexDecode("f90000"),
@@ -512,7 +515,7 @@ var unmarshalFloatTests = []unmarshalFloatTest{
512515
0.0,
513516
},
514517
{
515-
hexDecode("f90001"),
518+
hexDecode("f90001"), // float16 subnormal value
516519
float64(5.960464477539063e-08),
517520
[]interface{}{float32(5.960464477539063e-08), float64(5.960464477539063e-08)},
518521
[]reflect.Type{typeUint8, typeUint16, typeUint32, typeUint64, typeInt8, typeInt16, typeInt32, typeInt64, typeByteSlice, typeString, typeBool, typeIntSlice, typeMapStringInt},
@@ -632,7 +635,8 @@ var unmarshalFloatTests = []unmarshalFloatTest{
632635
[]reflect.Type{typeUint8, typeUint16, typeUint32, typeUint64, typeInt8, typeInt16, typeInt32, typeInt64, typeByteSlice, typeString, typeBool, typeIntSlice, typeMapStringInt},
633636
0.0,
634637
},
635-
// More float16 test data from "Half-precision"
638+
639+
// float16 test data from https://en.wikipedia.org/wiki/Half-precision_floating-point_format
636640
{
637641
hexDecode("f903ff"),
638642
float64(0.000060976),

0 commit comments

Comments
 (0)