@@ -536,6 +536,54 @@ func TestDataFrameFilterRowsByField(t *testing.T) {
536
536
}
537
537
}
538
538
539
+ func TestFrameTestCompareOptionsForConfFloat64 (t * testing.T ) {
540
+ var f1 data.ConfFloat64 = 1.23456789
541
+ var f2 data.ConfFloat64 = 2.3456789
542
+ var nan = data .ConfFloat64 (math .NaN ())
543
+ var posInf = data .ConfFloat64 (math .Inf (1 ))
544
+ var negInf = data .ConfFloat64 (math .Inf (- 1 ))
545
+ var pnil * data.ConfFloat64
546
+ t .Run ("ConfFloat64 should compare without crashing" , func (t * testing.T ) {
547
+ if diff := cmp .Diff (f1 , f1 , data .FrameTestCompareOptions ()... ); diff != "" {
548
+ t .Fatal (diff )
549
+ }
550
+ if diff := cmp .Diff (f1 , f2 , data .FrameTestCompareOptions ()... ); diff == "" {
551
+ t .Fatal ("Expecting diff, got nothing" )
552
+ }
553
+ })
554
+ t .Run ("*ConfFloat64 should compare without crashing" , func (t * testing.T ) {
555
+ if diff := cmp .Diff (& f1 , & f1 , data .FrameTestCompareOptions ()... ); diff != "" {
556
+ t .Fatal (diff )
557
+ }
558
+ if diff := cmp .Diff (& f1 , & f2 , data .FrameTestCompareOptions ()... ); diff == "" {
559
+ t .Fatal ("Expecting diff, got nothing" )
560
+ }
561
+ })
562
+ t .Run ("nil *ConfFloat64 should compare without crashing" , func (t * testing.T ) {
563
+ if diff := cmp .Diff (pnil , pnil , data .FrameTestCompareOptions ()... ); diff != "" {
564
+ t .Fatal (diff )
565
+ }
566
+ })
567
+ t .Run ("nil and non-nil *ConfFloat64 should compare without crashing" , func (t * testing.T ) {
568
+ if diff := cmp .Diff (& f1 , pnil , data .FrameTestCompareOptions ()... ); diff == "" {
569
+ t .Fatal ("Expecting diff, got nothing" )
570
+ }
571
+ if diff := cmp .Diff (pnil , & f1 , data .FrameTestCompareOptions ()... ); diff == "" {
572
+ t .Fatal ("Expecting diff, got nothing" )
573
+ }
574
+ })
575
+ t .Run ("nil *ConfFloat64 is equivalent to NaN/+Inf/-Inf" , func (t * testing.T ) {
576
+ for _ , p := range []* data.ConfFloat64 {& nan , & posInf , & negInf } {
577
+ if diff := cmp .Diff (pnil , p , data .FrameTestCompareOptions ()... ); diff != "" {
578
+ t .Fatal (diff )
579
+ }
580
+ if diff := cmp .Diff (p , pnil , data .FrameTestCompareOptions ()... ); diff != "" {
581
+ t .Fatal (diff )
582
+ }
583
+ }
584
+ })
585
+ }
586
+
539
587
func TestJSON (t * testing.T ) {
540
588
frames := data.Frames {
541
589
data .NewFrame ("http_requests_total" ,
0 commit comments