TestNormalizeForJSONSchema_Slice verifies recursive normalization of slices.
(t *testing.T)
| 1489 | |
| 1490 | // TestNormalizeForJSONSchema_Slice verifies recursive normalization of slices. |
| 1491 | func TestNormalizeForJSONSchema_Slice(t *testing.T) { |
| 1492 | input := []any{uint64(1), "two", int64(-3), true, nil, float64(4.5)} |
| 1493 | |
| 1494 | result := normalizeForJSONSchema(input) |
| 1495 | resultSlice, ok := result.([]any) |
| 1496 | if !ok { |
| 1497 | t.Fatalf("expected []any, got %T", result) |
| 1498 | } |
| 1499 | |
| 1500 | expected := []any{float64(1), "two", float64(-3), true, nil, float64(4.5)} |
| 1501 | if len(resultSlice) != len(expected) { |
| 1502 | t.Fatalf("length mismatch: got %d, want %d", len(resultSlice), len(expected)) |
| 1503 | } |
| 1504 | for i, want := range expected { |
| 1505 | if resultSlice[i] != want { |
| 1506 | t.Errorf("[%d]: got %T(%v), want %T(%v)", i, resultSlice[i], resultSlice[i], want, want) |
| 1507 | } |
| 1508 | } |
| 1509 | } |
| 1510 | |
| 1511 | // TestNormalizeForJSONSchema_TypedSlice verifies that typed slices (e.g. []string) |
| 1512 | // are converted to []any, since goccy/go-yaml may produce typed slices that the |
nothing calls this directly
no test coverage detected