Test ApplyFunc()
(t *testing.T)
| 175 | |
| 176 | // Test ApplyFunc() |
| 177 | func TestIntSetApplyFunc(t *testing.T) { |
| 178 | s := Create(1, 2, 3) |
| 179 | |
| 180 | // Double each value |
| 181 | result := s.ApplyFunc(func(val int) int { |
| 182 | return val * 2 |
| 183 | }) |
| 184 | |
| 185 | expected := Create(2, 4, 6) |
| 186 | if !result.Equals(expected) { |
| 187 | t.Fatalf("expected doubled values {2, 4, 6}, got: %v", result) |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | // Test with different comparable types |
| 192 | func TestFloat64Set(t *testing.T) { |