| 1 | package setscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/ |
| 2 | |
| 3 | import ( |
| 4 | "fmtscip-go gomod github.com/golang/go/src go1.18 fmt/" |
| 5 | "reflectscip-go gomod github.com/golang/go/src go1.18 reflect/" |
| 6 | "sortscip-go gomod github.com/golang/go/src go1.18 sort/" |
| 7 | "testingscip-go gomod github.com/golang/go/src go1.18 testing/" |
| 8 | ) |
| 9 | |
| 10 | // TestBasicSetOps tests the fundamental operations, whose implementations operate |
| 11 | // directly on the underlying data structure. The remaining operations are implemented |
| 12 | // in terms of these. |
| 13 | func TestBasicSetOpsscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/TestBasicSetOps().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 14 | s := NewSetscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSet().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().()) |
| 15 | want := map[int][]int{} |
| 16 | if !reflectscip-go gomod github.com/golang/go/src go1.18 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.18 reflect/DeepEqual().(s.valsscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#vals., want) { |
| 17 | t.Fatalfscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatalf().("new set has unexpected contents %#v; want %#v", s.valsscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#vals., want) |
| 18 | } |
| 19 | s.Addscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#Add().(1) |
| 20 | want[1] = []int{1} |
| 21 | if !reflectscip-go gomod github.com/golang/go/src go1.18 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.18 reflect/DeepEqual().(s.valsscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#vals., want) { |
| 22 | t.Fatalfscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatalf().("after s.Add(1) set has unexpected contents %#v; want %#v", s.valsscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#vals., want) |
| 23 | } |
| 24 | if !s.Hasscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#Has().(1) { |
| 25 | t.Fatalfscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatalf().("s.Has(1) returned false; want true") |
| 26 | } |
| 27 | s.Addscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#Add().(2) |
| 28 | want[2] = []int{2} |
| 29 | if !reflectscip-go gomod github.com/golang/go/src go1.18 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.18 reflect/DeepEqual().(s.valsscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#vals., want) { |
| 30 | t.Fatalfscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatalf().("after s.Add(2) set has unexpected contents %#v; want %#v", s.valsscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#vals., want) |
| 31 | } |
| 32 | if !s.Hasscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#Has().(2) { |
| 33 | t.Fatalfscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatalf().("s.Has(2) returned false; want true") |
| 34 | } |
| 35 | |
| 36 | // Our testRules cause 17 and 33 to return the same hash value as 1, so we can use this |
| 37 | // to test the situation where multiple values are in a bucket. |
| 38 | if s.Hasscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#Has().(17) { |
| 39 | t.Fatalfscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatalf().("s.Has(17) returned true; want false") |
| 40 | } |
| 41 | s.Addscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#Add().(17) |
| 42 | s.Addscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#Add().(33) |
| 43 | want[1] = append(want[1], 17, 33) |
| 44 | if !reflectscip-go gomod github.com/golang/go/src go1.18 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.18 reflect/DeepEqual().(s.valsscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#vals., want) { |
| 45 | t.Fatalfscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatalf().("after s.Add(17) and s.Add(33) set has unexpected contents %#v; want %#v", s.valsscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#vals., want) |
| 46 | } |
| 47 | if !s.Hasscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#Has().(17) { |
| 48 | t.Fatalfscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatalf().("s.Has(17) returned false; want true") |
| 49 | } |
| 50 | if !s.Hasscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#Has().(33) { |
| 51 | t.Fatalfscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatalf().("s.Has(33) returned false; want true") |
| 52 | } |
| 53 | |
| 54 | vals := make([]int, 0) |
| 55 | s.EachValuescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#EachValue().(func(v int) { |
| 56 | vals = append(vals, v) |
| 57 | }) |
| 58 | sortscip-go gomod github.com/golang/go/src go1.18 sort/.Intsscip-go gomod github.com/golang/go/src go1.18 sort/Ints().(vals) |
| 59 | if want := []int{1, 2, 17, 33}; !reflectscip-go gomod github.com/golang/go/src go1.18 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.18 reflect/DeepEqual().(vals, want) { |
| 60 | t.Fatalfscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatalf().("wrong values from EachValue %#v; want %#v", vals, want) |
| 61 | } |
| 62 | |
| 63 | s.Removescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#Remove().(2) |
| 64 | delete(want, 2) |
| 65 | if !reflectscip-go gomod github.com/golang/go/src go1.18 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.18 reflect/DeepEqual().(s.valsscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#vals., want) { |
| 66 | t.Fatalfscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatalf().("after s.Remove(2) set has unexpected contents %#v; want %#v", s.valsscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#vals., want) |
| 67 | } |
| 68 | |
| 69 | s.Removescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#Remove().(17) |
| 70 | want[1] = []int{1, 33} |
| 71 | if !reflectscip-go gomod github.com/golang/go/src go1.18 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.18 reflect/DeepEqual().(s.valsscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#vals., want) { |
| 72 | t.Fatalfscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatalf().("after s.Remove(17) set has unexpected contents %#v; want %#v", s.valsscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#vals., want) |
| 73 | } |
| 74 | |
| 75 | s.Removescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#Remove().(1) |
| 76 | want[1] = []int{33} |
| 77 | if !reflectscip-go gomod github.com/golang/go/src go1.18 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.18 reflect/DeepEqual().(s.valsscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#vals., want) { |
| 78 | t.Fatalfscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatalf().("after s.Remove(1) set has unexpected contents %#v; want %#v", s.valsscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#vals., want) |
| 79 | } |
| 80 | |
| 81 | s.Removescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#Remove().(33) |
| 82 | delete(want, 1) |
| 83 | if !reflectscip-go gomod github.com/golang/go/src go1.18 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.18 reflect/DeepEqual().(s.valsscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#vals., want) { |
| 84 | t.Fatalfscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatalf().("after s.Remove(33) set has unexpected contents %#v; want %#v", s.valsscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#vals., want) |
| 85 | } |
| 86 | |
| 87 | vals = make([]int, 0) |
| 88 | s.EachValuescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#EachValue().(func(v int) { |
| 89 | vals = append(vals, v) |
| 90 | }) |
| 91 | if len(vals) > 0 { |
| 92 | t.Fatalfscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatalf().("s.EachValue produced values %#v; want no calls", vals) |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | func TestUnionscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/TestUnion().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 97 | tests := []struct { |
| 98 | s1 Setscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#[int] |
| 99 | s2 Setscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#[int] |
| 100 | wantValues []int |
| 101 | }{ |
| 102 | { |
| 103 | NewSetscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSet().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().()), |
| 104 | NewSetscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSet().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().()), |
| 105 | nil, |
| 106 | }, |
| 107 | { |
| 108 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{1}), |
| 109 | NewSetscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSet().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().()), |
| 110 | []int{1}, |
| 111 | }, |
| 112 | { |
| 113 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{1}), |
| 114 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{2}), |
| 115 | []int{1, 2}, |
| 116 | }, |
| 117 | { |
| 118 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{1}), |
| 119 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{1}), |
| 120 | []int{1}, |
| 121 | }, |
| 122 | { |
| 123 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{17, 33}), |
| 124 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{1}), |
| 125 | []int{1, 17, 33}, |
| 126 | }, |
| 127 | { |
| 128 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{17, 33}), |
| 129 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{2, 1}), |
| 130 | []int{1, 2, 17, 33}, |
| 131 | }, |
| 132 | } |
| 133 | |
| 134 | for i, test := range tests { |
| 135 | t.Runscip-go gomod github.com/golang/go/src go1.18 testing/T#Run().(fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Sprintf().("%d", i), func(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 136 | got := test.s1.Unionscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#Union().(test.s2) |
| 137 | var gotValues []int |
| 138 | got.EachValuescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#EachValue().(func(v int) { |
| 139 | gotValues = append(gotValues, v) |
| 140 | }) |
| 141 | sortscip-go gomod github.com/golang/go/src go1.18 sort/.Intsscip-go gomod github.com/golang/go/src go1.18 sort/Ints().(gotValues) |
| 142 | sortscip-go gomod github.com/golang/go/src go1.18 sort/.Intsscip-go gomod github.com/golang/go/src go1.18 sort/Ints().(test.wantValues) |
| 143 | if !reflectscip-go gomod github.com/golang/go/src go1.18 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.18 reflect/DeepEqual().(gotValues, test.wantValues) { |
| 144 | s1Values := test.s1.Valuesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#Values().() |
| 145 | s2Values := test.s2.Valuesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#Values().() |
| 146 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().( |
| 147 | "wrong result %#v for %#v union %#v; want %#v", |
| 148 | gotValues, |
| 149 | s1Values, |
| 150 | s2Values, |
| 151 | test.wantValues, |
| 152 | ) |
| 153 | } |
| 154 | }) |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | func TestIntersectionscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/TestIntersection().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 159 | tests := []struct { |
| 160 | s1 Setscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#[int] |
| 161 | s2 Setscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#[int] |
| 162 | wantValues []int |
| 163 | }{ |
| 164 | { |
| 165 | NewSetscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSet().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().()), |
| 166 | NewSetscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSet().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().()), |
| 167 | nil, |
| 168 | }, |
| 169 | { |
| 170 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{1}), |
| 171 | NewSetscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSet().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().()), |
| 172 | nil, |
| 173 | }, |
| 174 | { |
| 175 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{1}), |
| 176 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{2}), |
| 177 | nil, |
| 178 | }, |
| 179 | { |
| 180 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{1}), |
| 181 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{1}), |
| 182 | []int{1}, |
| 183 | }, |
| 184 | { |
| 185 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{1, 17}), |
| 186 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{1, 2, 3}), |
| 187 | []int{1}, |
| 188 | }, |
| 189 | { |
| 190 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{3, 2, 1}), |
| 191 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{1, 2, 3}), |
| 192 | []int{1, 2, 3}, |
| 193 | }, |
| 194 | { |
| 195 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{17, 33}), |
| 196 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{1}), |
| 197 | nil, |
| 198 | }, |
| 199 | { |
| 200 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{17, 33}), |
| 201 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{2, 1}), |
| 202 | nil, |
| 203 | }, |
| 204 | } |
| 205 | |
| 206 | for i, test := range tests { |
| 207 | t.Runscip-go gomod github.com/golang/go/src go1.18 testing/T#Run().(fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Sprintf().("%d", i), func(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 208 | got := test.s1.Intersectionscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#Intersection().(test.s2) |
| 209 | var gotValues []int |
| 210 | got.EachValuescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#EachValue().(func(v int) { |
| 211 | gotValues = append(gotValues, v) |
| 212 | }) |
| 213 | sortscip-go gomod github.com/golang/go/src go1.18 sort/.Intsscip-go gomod github.com/golang/go/src go1.18 sort/Ints().(gotValues) |
| 214 | sortscip-go gomod github.com/golang/go/src go1.18 sort/.Intsscip-go gomod github.com/golang/go/src go1.18 sort/Ints().(test.wantValues) |
| 215 | if !reflectscip-go gomod github.com/golang/go/src go1.18 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.18 reflect/DeepEqual().(gotValues, test.wantValues) { |
| 216 | s1Values := test.s1.Valuesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#Values().() |
| 217 | s2Values := test.s2.Valuesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#Values().() |
| 218 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().( |
| 219 | "wrong result %#v for %#v intersection %#v; want %#v", |
| 220 | gotValues, |
| 221 | s1Values, |
| 222 | s2Values, |
| 223 | test.wantValues, |
| 224 | ) |
| 225 | } |
| 226 | }) |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | func TestSubtractscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/TestSubtract().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 231 | tests := []struct { |
| 232 | s1 Setscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#[int] |
| 233 | s2 Setscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#[int] |
| 234 | wantValues []int |
| 235 | }{ |
| 236 | { |
| 237 | NewSetscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSet().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().()), |
| 238 | NewSetscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSet().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().()), |
| 239 | nil, |
| 240 | }, |
| 241 | { |
| 242 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{1}), |
| 243 | NewSetscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSet().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().()), |
| 244 | []int{1}, |
| 245 | }, |
| 246 | { |
| 247 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{1}), |
| 248 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{2}), |
| 249 | []int{1}, |
| 250 | }, |
| 251 | { |
| 252 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{1}), |
| 253 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{1}), |
| 254 | nil, |
| 255 | }, |
| 256 | { |
| 257 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{1, 17}), |
| 258 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{1, 2, 3}), |
| 259 | []int{17}, |
| 260 | }, |
| 261 | { |
| 262 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{3, 2, 1}), |
| 263 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{1, 2, 3}), |
| 264 | nil, |
| 265 | }, |
| 266 | { |
| 267 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{17, 33}), |
| 268 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{1}), |
| 269 | []int{17, 33}, |
| 270 | }, |
| 271 | { |
| 272 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{17, 33}), |
| 273 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{2, 1}), |
| 274 | []int{17, 33}, |
| 275 | }, |
| 276 | } |
| 277 | |
| 278 | for i, test := range tests { |
| 279 | t.Runscip-go gomod github.com/golang/go/src go1.18 testing/T#Run().(fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Sprintf().("%d", i), func(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 280 | got := test.s1.Subtractscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#Subtract().(test.s2) |
| 281 | var gotValues []int |
| 282 | got.EachValuescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#EachValue().(func(v int) { |
| 283 | gotValues = append(gotValues, v) |
| 284 | }) |
| 285 | sortscip-go gomod github.com/golang/go/src go1.18 sort/.Intsscip-go gomod github.com/golang/go/src go1.18 sort/Ints().(gotValues) |
| 286 | sortscip-go gomod github.com/golang/go/src go1.18 sort/.Intsscip-go gomod github.com/golang/go/src go1.18 sort/Ints().(test.wantValues) |
| 287 | if !reflectscip-go gomod github.com/golang/go/src go1.18 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.18 reflect/DeepEqual().(gotValues, test.wantValues) { |
| 288 | s1Values := test.s1.Valuesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#Values().() |
| 289 | s2Values := test.s2.Valuesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#Values().() |
| 290 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().( |
| 291 | "wrong result %#v for %#v subtract %#v; want %#v", |
| 292 | gotValues, |
| 293 | s1Values, |
| 294 | s2Values, |
| 295 | test.wantValues, |
| 296 | ) |
| 297 | } |
| 298 | }) |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | func TestSymmetricDifferencescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/TestSymmetricDifference().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 303 | tests := []struct { |
| 304 | s1 Setscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#[int] |
| 305 | s2 Setscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#[int] |
| 306 | wantValues []int |
| 307 | }{ |
| 308 | { |
| 309 | NewSetscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSet().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().()), |
| 310 | NewSetscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSet().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().()), |
| 311 | nil, |
| 312 | }, |
| 313 | { |
| 314 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{1}), |
| 315 | NewSetscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSet().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().()), |
| 316 | []int{1}, |
| 317 | }, |
| 318 | { |
| 319 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{1}), |
| 320 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{2}), |
| 321 | []int{1, 2}, |
| 322 | }, |
| 323 | { |
| 324 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{1}), |
| 325 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{1}), |
| 326 | nil, |
| 327 | }, |
| 328 | { |
| 329 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{1, 17}), |
| 330 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{1, 2, 3}), |
| 331 | []int{2, 3, 17}, |
| 332 | }, |
| 333 | { |
| 334 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{3, 2, 1}), |
| 335 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{1, 2, 3}), |
| 336 | nil, |
| 337 | }, |
| 338 | { |
| 339 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{17, 33}), |
| 340 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{1}), |
| 341 | []int{1, 17, 33}, |
| 342 | }, |
| 343 | { |
| 344 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{17, 33}), |
| 345 | NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().(newTestRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/newTestRules().(), []int{2, 1}), |
| 346 | []int{1, 2, 17, 33}, |
| 347 | }, |
| 348 | } |
| 349 | |
| 350 | for i, test := range tests { |
| 351 | t.Runscip-go gomod github.com/golang/go/src go1.18 testing/T#Run().(fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Sprintf().("%d", i), func(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 352 | got := test.s1.SymmetricDifferencescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#SymmetricDifference().(test.s2) |
| 353 | var gotValues []int |
| 354 | got.EachValuescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#EachValue().(func(v int) { |
| 355 | gotValues = append(gotValues, v) |
| 356 | }) |
| 357 | sortscip-go gomod github.com/golang/go/src go1.18 sort/.Intsscip-go gomod github.com/golang/go/src go1.18 sort/Ints().(gotValues) |
| 358 | sortscip-go gomod github.com/golang/go/src go1.18 sort/.Intsscip-go gomod github.com/golang/go/src go1.18 sort/Ints().(test.wantValues) |
| 359 | if !reflectscip-go gomod github.com/golang/go/src go1.18 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.18 reflect/DeepEqual().(gotValues, test.wantValues) { |
| 360 | s1Values := test.s1.Valuesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#Values().() |
| 361 | s2Values := test.s2.Valuesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#Values().() |
| 362 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().( |
| 363 | "wrong result %#v for %#v symmetric difference %#v; want %#v", |
| 364 | gotValues, |
| 365 | s1Values, |
| 366 | s2Values, |
| 367 | test.wantValues, |
| 368 | ) |
| 369 | } |
| 370 | }) |
| 371 | } |
| 372 | } |