MCPcopy Create free account
hub / github.com/github/gh-aw / TestNormalizeForJSONSchema_Slice

Function TestNormalizeForJSONSchema_Slice

pkg/parser/schema_test.go:1491–1509  ·  view source on GitHub ↗

TestNormalizeForJSONSchema_Slice verifies recursive normalization of slices.

(t *testing.T)

Source from the content-addressed store, hash-verified

1489
1490// TestNormalizeForJSONSchema_Slice verifies recursive normalization of slices.
1491func 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

Callers

nothing calls this directly

Calls 2

normalizeForJSONSchemaFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected