Skip to content

Commit

Permalink
move test
Browse files Browse the repository at this point in the history
  • Loading branch information
candiduslynx committed Feb 20, 2024
1 parent be77f3d commit 79bb90b
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions reflect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,27 @@ func TestUnsignedIntHandling(t *testing.T) {
fixtureContains(t, "fixtures/unsigned_int_handling.json", `"maxItems": 0`)
}

type NullableWithOddFields struct {
SimpleMap map[string]string `json:"simple_map"`
MapWithNullableValues map[string]*string `json:"map_with_nullable_values"`

IntSlice []int `json:"int_slice"`
PointerToIntSlice *[]int `json:"pointer_to_int_slice"`
IntSliceWithNullableValues []*int `json:"int_slice_with_nullable_values"`
PointerToIntSliceWithNullableValues *[]*int `json:"pointer_to_int_slice_with_nullable_values"`

Chan chan int `json:"chan"`
UnsafePointer unsafe.Pointer `json:"unsafe_pointer"`
Reader io.Reader `json:"reader"`
}

func TestNullableFromType(t *testing.T) {
r := &Reflector{}
compareSchemaOutput(t, "fixtures/nullable_from_type_disabled.json", r, &NullableWithOddFields{})
r.NullableFromType = true
compareSchemaOutput(t, "fixtures/nullable_from_type_enabled.json", r, &NullableWithOddFields{})
}

type AliasObjectA struct {
PropA string `json:"prop_a"`
}
Expand Down Expand Up @@ -660,24 +681,3 @@ func TestJSONSchemaAlias(t *testing.T) {
compareSchemaOutput(t, "fixtures/schema_alias.json", r, &AliasObjectB{})
compareSchemaOutput(t, "fixtures/schema_alias_2.json", r, &AliasObjectC{})
}

type NullableWithOddFields struct {
SimpleMap map[string]string `json:"simple_map"`
MapWithNullableValues map[string]*string `json:"map_with_nullable_values"`

IntSlice []int `json:"int_slice"`
PointerToIntSlice *[]int `json:"pointer_to_int_slice"`
IntSliceWithNullableValues []*int `json:"int_slice_with_nullable_values"`
PointerToIntSliceWithNullableValues *[]*int `json:"pointer_to_int_slice_with_nullable_values"`

Chan chan int `json:"chan"`
UnsafePointer unsafe.Pointer `json:"unsafe_pointer"`
Reader io.Reader `json:"reader"`
}

func TestNullableFromType(t *testing.T) {
r := &Reflector{}
compareSchemaOutput(t, "fixtures/nullable_from_type_disabled.json", r, &NullableWithOddFields{})
r.NullableFromType = true
compareSchemaOutput(t, "fixtures/nullable_from_type_enabled.json", r, &NullableWithOddFields{})
}

0 comments on commit 79bb90b

Please sign in to comment.