11package ognl
22
33import (
4- "github.com/stretchr/testify/assert"
54 "testing"
5+
6+ "github.com/stretchr/testify/assert"
67)
78
89type Mock struct {
@@ -106,6 +107,17 @@ func TestGet(t *testing.T) {
106107 }
107108 }
108109
110+ for index , v := range test {
111+ vv := Get (* t1 , v .query )
112+ if ! assert .Equal (t , v .effective , vv .Effective ()) {
113+ t .Errorf ("effective fault expected:%t, got:%t, index:%d" , v .effective , vv .Effective (), index )
114+ return
115+ }
116+ if ! assert .Equal (t , v .value , vv .Value ()) {
117+ t .Errorf ("no equal index:%d, query:%s, expected:%v, got:%v" , index , v .query , v .value , vv .Value ())
118+ }
119+ }
120+
109121 p := Parse (t1 )
110122 for index , v := range test {
111123 vv := p .Get (v .query )
@@ -118,6 +130,18 @@ func TestGet(t *testing.T) {
118130 }
119131 }
120132
133+ p = Parse (* t1 )
134+ for index , v := range test {
135+ vv := p .Get (v .query )
136+ if ! assert .Equal (t , v .effective , vv .Effective ()) {
137+ t .Errorf ("effective fault expected:%t, got:%t" , v .effective , vv .Effective ())
138+ return
139+ }
140+ if ! assert .Equal (t , v .value , vv .Value ()) {
141+ t .Errorf ("no equal index:%d, query:%s, expected:%v, got:%v" , index , v .query , v .value , vv .Value ())
142+ }
143+ }
144+
121145 test = []struct {
122146 query string
123147 value interface {}
@@ -147,6 +171,18 @@ func TestGet(t *testing.T) {
147171 }
148172 }
149173
174+ g1 = Get (* t1 , "List" )
175+ for index , v := range test {
176+ vv := g1 .Get (v .query )
177+ if ! assert .Equal (t , v .effective , vv .Effective ()) {
178+ t .Errorf ("effective fault expected:%t, got:%t" , v .effective , vv .Effective ())
179+ return
180+ }
181+ if ! assert .Equal (t , v .value , vv .Value ()) {
182+ t .Errorf ("no equal index:%d, query:%s, expected:%v, got:%v" , index , v .query , v .value , vv .Value ())
183+ }
184+ }
185+
150186 test = []struct {
151187 query string
152188 value interface {}
@@ -166,4 +202,16 @@ func TestGet(t *testing.T) {
166202 t .Errorf ("no equal index:%d, query:%s, expected:%v, got:%v" , index , v .query , v .value , vv .Value ())
167203 }
168204 }
205+
206+ g1 = Get (* t1 , "" )
207+ for index , v := range test {
208+ vv := g1 .Get (v .query )
209+ if ! assert .Equal (t , v .effective , vv .Effective ()) {
210+ t .Errorf ("effective fault expected:%t, got:%t" , v .effective , vv .Effective ())
211+ return
212+ }
213+ if ! assert .Equal (t , v .value , vv .Values ()) {
214+ t .Errorf ("no equal index:%d, query:%s, expected:%v, got:%v" , index , v .query , v .value , vv .Value ())
215+ }
216+ }
169217}
0 commit comments