(t *testing.T)
| 563 | } |
| 564 | |
| 565 | func TestStatic_compare(t *testing.T) { |
| 566 | testCases := []struct { |
| 567 | s1, s2 Static |
| 568 | want int |
| 569 | }{ |
| 570 | {s1: NewStaticInt(10), s2: NewStaticInt(5), want: 1}, |
| 571 | {s1: NewStaticInt(5), s2: NewStaticInt(-10), want: 1}, |
| 572 | {s1: NewStaticInt(20), s2: NewStaticInt(20), want: 0}, |
| 573 | {s1: NewStaticFloat(10.5), s2: NewStaticFloat(5.5), want: 1}, |
| 574 | {s1: NewStaticFloat(100.0), s2: NewStaticInt(100), want: 0}, |
| 575 | {s1: NewStaticFloat(100.0), s2: NewStaticInt(50), want: 1}, |
| 576 | {s1: NewStaticString("world"), s2: NewStaticString("hello"), want: 1}, |
| 577 | {s1: NewStaticBool(true), s2: NewStaticBool(false), want: 1}, |
| 578 | {s1: NewStaticDuration(10 * time.Second), s2: NewStaticDuration(5 * time.Second), want: 1}, |
| 579 | {s1: NewStaticDuration(10), s2: NewStaticInt(10), want: 0}, |
| 580 | {s1: NewStaticIntArray([]int{1, 3, 3}), s2: NewStaticIntArray([]int{1, -2, 3}), want: 1}, |
| 581 | {s1: NewStaticIntArray([]int{1, 2, 3}), s2: NewStaticIntArray([]int{1, 2, 3}), want: 0}, |
| 582 | {s1: NewStaticFloatArray([]float64{1.1, math.SmallestNonzeroFloat64}), s2: NewStaticFloatArray([]float64{1.1, 0}), want: 1}, |
| 583 | {s1: NewStaticFloatArray([]float64{1.1, 2.2, 3.3}), s2: NewStaticFloatArray([]float64{1.1, -2.2, 3.3}), want: 1}, |
| 584 | {s1: NewStaticFloatArray([]float64{1.1, 2.2, 3.3}), s2: NewStaticFloatArray([]float64{1.1, 2.2, 3.3}), want: 0}, |
| 585 | {s1: NewStaticStringArray([]string{"a", "b", "c"}), s2: NewStaticStringArray([]string{"a", "b"}), want: 1}, |
| 586 | {s1: NewStaticStringArray([]string{"a", "b"}), s2: NewStaticStringArray([]string{"a", "b"}), want: 0}, |
| 587 | {s1: NewStaticBooleanArray([]bool{true, false, true}), s2: NewStaticBooleanArray([]bool{true, false}), want: 1}, |
| 588 | {s1: NewStaticBooleanArray([]bool{true, false}), s2: NewStaticBooleanArray([]bool{true, false}), want: 0}, |
| 589 | } |
| 590 | |
| 591 | for _, tt := range testCases { |
| 592 | t.Run(fmt.Sprintf("%s<>%s", tt.s1.String(), tt.s2.String()), func(t *testing.T) { |
| 593 | res := tt.s1.compare(&tt.s2) |
| 594 | require.Equal(t, tt.want, res, "s1.compare(s2)") |
| 595 | res = tt.s2.compare(&tt.s1) |
| 596 | require.Equal(t, -tt.want, res, "s2.compare(s1)") |
| 597 | }) |
| 598 | } |
| 599 | } |
| 600 | |
| 601 | func TestStatic_sumInto(t *testing.T) { |
| 602 | tests := []struct { |
nothing calls this directly
no test coverage detected