IntSet.ToSlice() is called with series of cases for valid and erroneous inputs and the result is validated.
(t *testing.T)
| 85 | |
| 86 | // IntSet.ToSlice() is called with series of cases for valid and erroneous inputs and the result is validated. |
| 87 | func TestIntSetToSlice(t *testing.T) { |
| 88 | testCases := []struct { |
| 89 | set IntSet |
| 90 | expectedResult []int |
| 91 | }{ |
| 92 | // Test empty set. |
| 93 | {NewIntSet(), []int{}}, |
| 94 | // Test set with value. |
| 95 | {CreateIntSet(42), []int{42}}, |
| 96 | // Test set with multiple values (should be sorted). |
| 97 | {CreateIntSet(3, 1, 2), []int{1, 2, 3}}, |
| 98 | } |
| 99 | |
| 100 | for _, testCase := range testCases { |
| 101 | islice := testCase.set.ToSlice() |
| 102 | if !reflect.DeepEqual(islice, testCase.expectedResult) { |
| 103 | t.Fatalf("expected: %v, got: %v", testCase.expectedResult, islice) |
| 104 | } |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | func TestIntSet_UnmarshalJSON(t *testing.T) { |
| 109 | type args struct { |
nothing calls this directly
no test coverage detected