mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-06 12:37:49 +00:00
Added another test to check slices of bools in model_builder
Signed-off-by: Dave Shanley <dave@quobix.com>
This commit is contained in:
@@ -337,11 +337,6 @@ func TestSetField_Default_Helper(t *testing.T) {
|
|||||||
|
|
||||||
func TestHandleSlicesOfInts(t *testing.T) {
|
func TestHandleSlicesOfInts(t *testing.T) {
|
||||||
|
|
||||||
type cake struct {
|
|
||||||
thing int
|
|
||||||
}
|
|
||||||
|
|
||||||
// this should be ignored, no custom objects in here my friend.
|
|
||||||
type internal struct {
|
type internal struct {
|
||||||
Thing NodeReference[[]ValueReference[any]]
|
Thing NodeReference[[]ValueReference[any]]
|
||||||
}
|
}
|
||||||
@@ -361,6 +356,26 @@ func TestHandleSlicesOfInts(t *testing.T) {
|
|||||||
assert.Equal(t, 1.234, ins.Thing.Value[1].Value)
|
assert.Equal(t, 1.234, ins.Thing.Value[1].Value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestHandleSlicesOfBools(t *testing.T) {
|
||||||
|
type internal struct {
|
||||||
|
Thing NodeReference[[]ValueReference[any]]
|
||||||
|
}
|
||||||
|
|
||||||
|
yml := `thing:
|
||||||
|
- true
|
||||||
|
- false`
|
||||||
|
|
||||||
|
ins := new(internal)
|
||||||
|
var rootNode yaml.Node
|
||||||
|
mErr := yaml.Unmarshal([]byte(yml), &rootNode)
|
||||||
|
assert.NoError(t, mErr)
|
||||||
|
|
||||||
|
try := BuildModel(rootNode.Content[0], ins)
|
||||||
|
assert.NoError(t, try)
|
||||||
|
assert.Equal(t, true, ins.Thing.Value[0].Value)
|
||||||
|
assert.Equal(t, false, ins.Thing.Value[1].Value)
|
||||||
|
}
|
||||||
|
|
||||||
func TestSetField_Ignore(t *testing.T) {
|
func TestSetField_Ignore(t *testing.T) {
|
||||||
|
|
||||||
type Complex struct {
|
type Complex struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user