@@ -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" ,
@@ -718,25 +709,31 @@ func TestDecode(t *testing.T) {
718
709
assertOnError : assertNilError ,
719
710
},
720
711
{
721
- name : "tag 1 with a positive infinity" ,
722
- in : hex ("c1f97c00" ), // 1(Infinity)
723
- want : "0001-01-01T00:00:00Z" ,
724
- fixme : "decoding cbor data tagged with 1 produces time.Time instead of RFC3339 timestamp string" ,
725
- assertOnError : assertNilError ,
712
+ name : "tag 1 with a positive infinity" ,
713
+ in : hex ("c1f97c00" ), // 1(Infinity)
714
+ assertOnError : assertOnConcreteError (func (t * testing.T , e * cbor.UnacceptableDataItemError ) {
715
+ if diff := cmp .Diff (& cbor.UnacceptableDataItemError {CBORType : "primitives" , Message : "floating-point infinity" }, e ); diff != "" {
716
+ t .Errorf ("unexpected error diff:\n %s" , diff )
717
+ }
718
+ }),
726
719
},
727
720
{
728
- name : "tag 1 with a negative infinity" ,
729
- in : hex ("c1f9fc00" ), // 1(-Infinity)
730
- want : "0001-01-01T00:00:00Z" ,
731
- fixme : "decoding cbor data tagged with 1 produces time.Time instead of RFC3339 timestamp string" ,
732
- assertOnError : assertNilError ,
721
+ name : "tag 1 with a negative infinity" ,
722
+ in : hex ("c1f9fc00" ), // 1(-Infinity)
723
+ assertOnError : assertOnConcreteError (func (t * testing.T , e * cbor.UnacceptableDataItemError ) {
724
+ if diff := cmp .Diff (& cbor.UnacceptableDataItemError {CBORType : "primitives" , Message : "floating-point infinity" }, e ); diff != "" {
725
+ t .Errorf ("unexpected error diff:\n %s" , diff )
726
+ }
727
+ }),
733
728
},
734
729
{
735
- name : "tag 1 with NaN" ,
736
- in : hex ("c1f9fc00" ), // 1(NaN)
737
- want : "0001-01-01T00:00:00Z" ,
738
- fixme : "decoding cbor data tagged with 1 produces time.Time instead of RFC3339 timestamp string" ,
739
- assertOnError : assertNilError ,
730
+ name : "tag 1 with NaN" ,
731
+ in : hex ("c1f97e00" ), // 1(NaN)
732
+ assertOnError : assertOnConcreteError (func (t * testing.T , e * cbor.UnacceptableDataItemError ) {
733
+ if diff := cmp .Diff (& cbor.UnacceptableDataItemError {CBORType : "primitives" , Message : "floating-point NaN" }, e ); diff != "" {
734
+ t .Errorf ("unexpected error diff:\n %s" , diff )
735
+ }
736
+ }),
740
737
},
741
738
})
742
739
0 commit comments