@@ -435,92 +435,83 @@ func TestDecode(t *testing.T) {
435
435
{
436
436
name : "half precision infinity" ,
437
437
in : hex ("f97c00" ),
438
- assertOnError : func (t * testing.T , e error ) {
439
- if e == nil {
440
- t .Fatal ( "expected non-nil error" )
438
+ assertOnError : assertOnConcreteError ( func (t * testing.T , e * cbor. UnacceptableDataItemError ) {
439
+ if diff := cmp . Diff ( & cbor. UnacceptableDataItemError { CBORType : "primitives" , Message : "floating-point infinity" }, e ); diff != "" {
440
+ t .Errorf ( "unexpected error diff: \n %s" , diff )
441
441
}
442
- },
443
- fixme : "NaN and positive/negative infinities should be rejected" ,
442
+ }),
444
443
},
445
444
{
446
445
name : "single precision infinity" ,
447
446
in : hex ("fa7f800000" ),
448
- assertOnError : func (t * testing.T , e error ) {
449
- if e == nil {
450
- t .Fatal ( "expected non-nil error" )
447
+ assertOnError : assertOnConcreteError ( func (t * testing.T , e * cbor. UnacceptableDataItemError ) {
448
+ if diff := cmp . Diff ( & cbor. UnacceptableDataItemError { CBORType : "primitives" , Message : "floating-point infinity" }, e ); diff != "" {
449
+ t .Errorf ( "unexpected error diff: \n %s" , diff )
451
450
}
452
- },
453
- fixme : "NaN and positive/negative infinities should be rejected" ,
451
+ }),
454
452
},
455
453
{
456
454
name : "double precision infinity" ,
457
455
in : hex ("fb7ff0000000000000" ),
458
- assertOnError : func (t * testing.T , e error ) {
459
- if e == nil {
460
- t .Fatal ( "expected non-nil error" )
456
+ assertOnError : assertOnConcreteError ( func (t * testing.T , e * cbor. UnacceptableDataItemError ) {
457
+ if diff := cmp . Diff ( & cbor. UnacceptableDataItemError { CBORType : "primitives" , Message : "floating-point infinity" }, e ); diff != "" {
458
+ t .Errorf ( "unexpected error diff: \n %s" , diff )
461
459
}
462
- },
463
- fixme : "NaN and positive/negative infinities should be rejected" ,
460
+ }),
464
461
},
465
462
{
466
463
name : "half precision negative infinity" ,
467
464
in : hex ("f9fc00" ),
468
- assertOnError : func (t * testing.T , e error ) {
469
- if e == nil {
470
- t .Fatal ( "expected non-nil error" )
465
+ assertOnError : assertOnConcreteError ( func (t * testing.T , e * cbor. UnacceptableDataItemError ) {
466
+ if diff := cmp . Diff ( & cbor. UnacceptableDataItemError { CBORType : "primitives" , Message : "floating-point infinity" }, e ); diff != "" {
467
+ t .Errorf ( "unexpected error diff: \n %s" , diff )
471
468
}
472
- },
473
- fixme : "NaN and positive/negative infinities should be rejected" ,
469
+ }),
474
470
},
475
471
{
476
472
name : "single precision negative infinity" ,
477
473
in : hex ("faff800000" ),
478
- assertOnError : func (t * testing.T , e error ) {
479
- if e == nil {
480
- t .Fatal ( "expected non-nil error" )
474
+ assertOnError : assertOnConcreteError ( func (t * testing.T , e * cbor. UnacceptableDataItemError ) {
475
+ if diff := cmp . Diff ( & cbor. UnacceptableDataItemError { CBORType : "primitives" , Message : "floating-point infinity" }, e ); diff != "" {
476
+ t .Errorf ( "unexpected error diff: \n %s" , diff )
481
477
}
482
- },
483
- fixme : "NaN and positive/negative infinities should be rejected" ,
478
+ }),
484
479
},
485
480
{
486
481
name : "double precision negative infinity" ,
487
482
in : hex ("fbfff0000000000000" ),
488
- assertOnError : func (t * testing.T , e error ) {
489
- if e == nil {
490
- t .Fatal ( "expected non-nil error" )
483
+ assertOnError : assertOnConcreteError ( func (t * testing.T , e * cbor. UnacceptableDataItemError ) {
484
+ if diff := cmp . Diff ( & cbor. UnacceptableDataItemError { CBORType : "primitives" , Message : "floating-point infinity" }, e ); diff != "" {
485
+ t .Errorf ( "unexpected error diff: \n %s" , diff )
491
486
}
492
- },
493
- fixme : "NaN and positive/negative infinities should be rejected" ,
487
+ }),
494
488
},
495
489
{
496
490
name : "half precision NaN" ,
497
491
in : hex ("f97e00" ),
498
- assertOnError : func (t * testing.T , e error ) {
499
- if e == nil {
500
- t .Fatal ( "expected non-nil error" )
492
+ assertOnError : assertOnConcreteError ( func (t * testing.T , e * cbor. UnacceptableDataItemError ) {
493
+ if diff := cmp . Diff ( & cbor. UnacceptableDataItemError { CBORType : "primitives" , Message : "floating-point NaN" }, e ); diff != "" {
494
+ t .Errorf ( "unexpected error diff: \n %s" , diff )
501
495
}
502
- },
503
- fixme : "NaN and positive/negative infinities should be rejected" ,
496
+ }),
504
497
},
505
498
{
506
499
name : "single precision NaN" ,
507
500
in : hex ("fa7fc00000" ),
508
- assertOnError : func (t * testing.T , e error ) {
509
- if e == nil {
510
- t .Fatal ( "expected non-nil error" )
501
+ assertOnError : assertOnConcreteError ( func (t * testing.T , e * cbor. UnacceptableDataItemError ) {
502
+ if diff := cmp . Diff ( & cbor. UnacceptableDataItemError { CBORType : "primitives" , Message : "floating-point NaN" }, e ); diff != "" {
503
+ t .Errorf ( "unexpected error diff: \n %s" , diff )
511
504
}
512
- },
513
- fixme : "NaN and positive/negative infinities should be rejected" ,
505
+ }),
514
506
},
515
507
{
516
508
name : "double precision NaN" ,
517
509
in : hex ("fb7ff8000000000000" ),
518
- assertOnError : func (t * testing.T , e error ) {
519
- if e == nil {
520
- t .Fatal ( "expected non-nil error" )
510
+ assertOnError : assertOnConcreteError ( func (t * testing.T , e * cbor. UnacceptableDataItemError ) {
511
+ if diff := cmp . Diff ( & cbor. UnacceptableDataItemError { CBORType : "primitives" , Message : "floating-point NaN" }, e ); diff != "" {
512
+ t .Errorf ( "unexpected error diff: \n %s" , diff )
521
513
}
522
- },
523
- fixme : "NaN and positive/negative infinities should be rejected" ,
514
+ }),
524
515
},
525
516
{
526
517
name : "smallest nonzero float64" ,
@@ -728,25 +719,31 @@ func TestDecode(t *testing.T) {
728
719
assertOnError : assertNilError ,
729
720
},
730
721
{
731
- name : "tag 1 with a positive infinity" ,
732
- in : hex ("c1f97c00" ), // 1(Infinity)
733
- want : "0001-01-01T00:00:00Z" ,
734
- fixme : "decoding cbor data tagged with 1 produces time.Time instead of RFC3339 timestamp string" ,
735
- assertOnError : assertNilError ,
722
+ name : "tag 1 with a positive infinity" ,
723
+ in : hex ("c1f97c00" ), // 1(Infinity)
724
+ assertOnError : assertOnConcreteError (func (t * testing.T , e * cbor.UnacceptableDataItemError ) {
725
+ if diff := cmp .Diff (& cbor.UnacceptableDataItemError {CBORType : "primitives" , Message : "floating-point infinity" }, e ); diff != "" {
726
+ t .Errorf ("unexpected error diff:\n %s" , diff )
727
+ }
728
+ }),
736
729
},
737
730
{
738
- name : "tag 1 with a negative infinity" ,
739
- in : hex ("c1f9fc00" ), // 1(-Infinity)
740
- want : "0001-01-01T00:00:00Z" ,
741
- fixme : "decoding cbor data tagged with 1 produces time.Time instead of RFC3339 timestamp string" ,
742
- assertOnError : assertNilError ,
731
+ name : "tag 1 with a negative infinity" ,
732
+ in : hex ("c1f9fc00" ), // 1(-Infinity)
733
+ assertOnError : assertOnConcreteError (func (t * testing.T , e * cbor.UnacceptableDataItemError ) {
734
+ if diff := cmp .Diff (& cbor.UnacceptableDataItemError {CBORType : "primitives" , Message : "floating-point infinity" }, e ); diff != "" {
735
+ t .Errorf ("unexpected error diff:\n %s" , diff )
736
+ }
737
+ }),
743
738
},
744
739
{
745
- name : "tag 1 with NaN" ,
746
- in : hex ("c1f9fc00" ), // 1(NaN)
747
- want : "0001-01-01T00:00:00Z" ,
748
- fixme : "decoding cbor data tagged with 1 produces time.Time instead of RFC3339 timestamp string" ,
749
- assertOnError : assertNilError ,
740
+ name : "tag 1 with NaN" ,
741
+ in : hex ("c1f97e00" ), // 1(NaN)
742
+ assertOnError : assertOnConcreteError (func (t * testing.T , e * cbor.UnacceptableDataItemError ) {
743
+ if diff := cmp .Diff (& cbor.UnacceptableDataItemError {CBORType : "primitives" , Message : "floating-point NaN" }, e ); diff != "" {
744
+ t .Errorf ("unexpected error diff:\n %s" , diff )
745
+ }
746
+ }),
750
747
},
751
748
})
752
749
0 commit comments