Skip to content

Commit 5f74b03

Browse files
committed
added test to validate min-max panic.
1 parent de590c9 commit 5f74b03

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

renderer/schema_renderer_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2370,6 +2370,33 @@ func TestSchemaRenderer_RandomWord_RecursiveCall(t *testing.T) {
23702370
"Expected 'dddddddd' or 'eeeeeeeee', got '%s'", result)
23712371
}
23722372

2373+
func TestSchemaRenderer_RandomInt_DegenerateBounds(t *testing.T) {
2374+
wr := &SchemaRenderer{
2375+
rand: rand.New(rand.NewSource(42)),
2376+
}
2377+
2378+
assert.Equal(t, int64(7), wr.RandomInt(7, 7))
2379+
assert.Equal(t, int64(9), wr.RandomInt(9, 3))
2380+
}
2381+
2382+
func TestRenderExample_IntegerWithEqualBounds(t *testing.T) {
2383+
testObject := `type: integer
2384+
minimum: 5
2385+
maximum: 5`
2386+
2387+
compiled := getSchema([]byte(testObject))
2388+
2389+
journeyMap := make(map[string]any)
2390+
visited := createVisitedMap()
2391+
wr := createSchemaRenderer()
2392+
2393+
assert.NotPanics(t, func() {
2394+
wr.DiveIntoSchema(compiled, "pb33f", journeyMap, visited, 0)
2395+
})
2396+
2397+
assert.Equal(t, int64(5), journeyMap["pb33f"])
2398+
}
2399+
23732400
func TestDiveIntoSchema_NilSchema(t *testing.T) {
23742401
wr := createSchemaRenderer()
23752402
structure := make(map[string]any)

0 commit comments

Comments
 (0)