(t *testing.T)
| 9 | func (Expr) EvalName() string { return "test expression" } |
| 10 | |
| 11 | func TestToExpressionSet(t *testing.T) { |
| 12 | cases := []struct { |
| 13 | Name string |
| 14 | Slice []any |
| 15 | ExpectPanic bool |
| 16 | }{ |
| 17 | {"simple", []any{Expr(42)}, false}, |
| 18 | {"nil", nil, false}, |
| 19 | {"invalid", []any{42}, true}, |
| 20 | } |
| 21 | for _, c := range cases { |
| 22 | t.Run(c.Name, func(t *testing.T) { |
| 23 | defer func() { |
| 24 | if r := recover(); r == nil && c.ExpectPanic { |
| 25 | t.Errorf("test did not panic") |
| 26 | } |
| 27 | }() |
| 28 | set := ToExpressionSet(c.Slice) |
| 29 | if len(set) != len(c.Slice) { |
| 30 | t.Errorf("got set of length %d, expected %d.", len(set), len(c.Slice)) |
| 31 | } else { |
| 32 | for i, e := range set { |
| 33 | if e != c.Slice[i] { |
| 34 | t.Errorf("got value %v at index %d, expected %v", e, i, c.Slice[i]) |
| 35 | } |
| 36 | } |
| 37 | } |
| 38 | }) |
| 39 | } |
| 40 | } |
nothing calls this directly
no test coverage detected