@@ -197,6 +197,23 @@ func (t test2) GetValue() *yaml.Node {
197197	return  nil 
198198}
199199
200+ type  structLowTest  struct  {
201+ 	Name  string  `yaml:"name,omitempty"` 
202+ }
203+ 
204+ type  nonEmptyExample  struct {}
205+ 
206+ var  nonEmptyExampleCallCount  int 
207+ 
208+ func  (nonEmptyExample ) IsEmpty () bool  {
209+ 	nonEmptyExampleCallCount ++ 
210+ 	return  false 
211+ }
212+ 
213+ type  pointerFieldStruct  struct  {
214+ 	Example  * nonEmptyExample  `yaml:"example,omitempty"` 
215+ }
216+ 
200217func  TestNewNodeBuilder_SliceRef_Inline_HasValue (t  * testing.T ) {
201218	ty  :=  []interface {}{utils .CreateEmptySequenceNode ()}
202219	t1  :=  test1 {
@@ -1172,3 +1189,37 @@ func TestNewNodeBuilder_DescriptionOmitEmpty(t *testing.T) {
11721189
11731190	assert .Equal (t , desired , strings .TrimSpace (string (data )))
11741191}
1192+ 
1193+ func  TestNodeBuilder_LowStructValueAccess (t  * testing.T ) {
1194+ 	high  :=  & structLowTest {
1195+ 		Name : "libopenapi" ,
1196+ 	}
1197+ 	low  :=  structLowTest {
1198+ 		Name : "libopenapi" ,
1199+ 	}
1200+ 
1201+ 	nb  :=  NewNodeBuilder (high , low )
1202+ 	node  :=  nb .Render ()
1203+ 
1204+ 	data , _  :=  yaml .Marshal (node )
1205+ 
1206+ 	assert .Equal (t , "name: libopenapi" , strings .TrimSpace (string (data )))
1207+ }
1208+ 
1209+ func  TestNodeBuilder_LowPointerIsNotEmpty (t  * testing.T ) {
1210+ 	nonEmptyExampleCallCount  =  0 
1211+ 	high  :=  & pointerFieldStruct {}
1212+ 	low  :=  & pointerFieldStruct {
1213+ 		Example : & nonEmptyExample {},
1214+ 	}
1215+ 
1216+ 	nb  :=  NewNodeBuilder (high , low )
1217+ 
1218+ 	assert .Equal (t , 1 , nonEmptyExampleCallCount )
1219+ 
1220+ 	node  :=  nb .Render ()
1221+ 	data , _  :=  yaml .Marshal (node )
1222+ 
1223+ 	output  :=  strings .TrimSpace (string (data ))
1224+ 	assert .Equal (t , "{}" , output )
1225+ }
0 commit comments