| 131 | } |
| 132 | |
| 133 | func TestLimit(t *testing.T) { |
| 134 | for _, test := range []struct { |
| 135 | values []string |
| 136 | limit int |
| 137 | want []string |
| 138 | }{ |
| 139 | { |
| 140 | values: []string{"a", "b", "c"}, |
| 141 | limit: 3, |
| 142 | want: []string{"a", "b", "c"}, |
| 143 | }, |
| 144 | { |
| 145 | values: []string{"a", "b", "c"}, |
| 146 | limit: 4, |
| 147 | want: []string{"a", "b", "c"}, |
| 148 | }, |
| 149 | { |
| 150 | values: []string{"a", "b", "c"}, |
| 151 | limit: 2, |
| 152 | want: []string{"a", "b"}, |
| 153 | }, |
| 154 | { |
| 155 | values: []string{"a", "b", "c"}, |
| 156 | limit: 1, |
| 157 | want: []string{"a"}, |
| 158 | }, |
| 159 | { |
| 160 | values: []string{"a", "b", "c"}, |
| 161 | limit: 0, |
| 162 | want: []string{}, |
| 163 | }, |
| 164 | { |
| 165 | values: []string{}, |
| 166 | limit: 0, |
| 167 | want: []string{}, |
| 168 | }, |
| 169 | } { |
| 170 | if got := Limit(test.values, test.limit); !assert.EqualValues(t, got, test.want) { |
| 171 | t.Errorf("Limit(%v, %d) = %v; want %v", test.values, test.limit, got, test.want) |
| 172 | } |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | func TestLimitStr(t *testing.T) { |
| 177 | for _, test := range []struct { |