@@ -15,21 +15,14 @@ func TestBasicMatching(t *testing.T) {
1515 t .Error (err .Error ())
1616 }
1717 shouldMatch := []string {
18- `{"a": 2, "b": "3", "x": 33}` ,
1918 `{"b": "3", "a": 1}` ,
19+ `{"a": 2, "b": "3", "x": 33}` ,
2020 }
2121 shouldNotMatch := []string {
2222 `{"b": "3", "a": 6}` ,
2323 `{"a": 2}` ,
2424 `{"b": "3"}` ,
2525 }
26- for _ , shouldNot := range shouldNotMatch {
27- var matches []X
28- matches , err = m .MatchesForJSONEvent ([]byte (shouldNot ))
29- if len (matches ) != 0 {
30- t .Error ("Matched: " + shouldNot )
31- }
32- }
3326 for _ , should := range shouldMatch {
3427 var matches []X
3528 matches , err = m .MatchesForJSONEvent ([]byte (should ))
@@ -40,6 +33,13 @@ func TestBasicMatching(t *testing.T) {
4033 t .Errorf ("event %s, LM %d" , should , len (matches ))
4134 }
4235 }
36+ for _ , shouldNot := range shouldNotMatch {
37+ var matches []X
38+ matches , err = m .MatchesForJSONEvent ([]byte (shouldNot ))
39+ if len (matches ) != 0 {
40+ t .Error ("Matched: " + shouldNot )
41+ }
42+ }
4343}
4444
4545func TestExerciseMatching (t * testing.T ) {
@@ -49,7 +49,7 @@ func TestExerciseMatching(t *testing.T) {
4949 "Height": 600,
5050 "Title": "View from 15th Floor",
5151 "Thumbnail": {
52- "Url": "http ://www.example.com/image/481989943",
52+ "Url": "https ://www.example.com/image/481989943",
5353 "Height": 125,
5454 "Width": 100
5555 },
@@ -128,64 +128,9 @@ func TestSimpleAddPattern(t *testing.T) {
128128 t .Errorf ("s0 trans len %d" , len (s0 .transitions ))
129129 }
130130
131- v0 , ok := s0 .transitions ["a" ]
131+ _ , ok := s0 .transitions ["a" ]
132132 if ! ok {
133133 t .Error ("No trans from start on 'a'" )
134134 }
135- if len (v0 .valueTransitions ) != 2 {
136- t .Errorf ("v1 trans %d wanted 2" , len (v0 .valueTransitions ))
137- }
138- s1 , ok := v0 .valueTransitions ["1" ]
139- if ! ok {
140- t .Error ("no trans on 1 fro s1" )
141- }
142- s2 , ok := v0 .valueTransitions ["2" ]
143- if ! ok {
144- t .Error ("no trans on 2 from s2" )
145- }
146- if len (s1 .transitions ) != 1 {
147- t .Errorf ("s1 trans len %d" , len (s1 .transitions ))
148- }
149- if len (s2 .transitions ) != 1 {
150- t .Errorf ("s2 trans len %d" , len (s2 .transitions ))
151- }
152- v1 , ok := s1 .transitions ["b" ]
153- if ! ok {
154- t .Error ("no trans on b from s1" )
155- }
156- v2 , ok := s2 .transitions ["b" ]
157- if ! ok {
158- t .Error ("no trans on b from s2" )
159- }
160- for _ , v := range []* valueMatchState {v1 , v2 } {
161- if len (v .valueTransitions ) != 2 {
162- t .Errorf ("trans len on %v = %d" , v , len (v .valueTransitions ))
163- }
164- s3 , ok := v .valueTransitions ["1" ]
165- if ! ok {
166- t .Error ("no trans on 1 at s3" )
167- }
168- if len (s3 .transitions ) != 0 {
169- t .Errorf ("len trans s3 = %d" , len (s3 .transitions ))
170- }
171- if len (s3 .matches ) != 1 {
172- t .Errorf ("s3 matches %d" , len (s3 .matches ))
173- }
174- if s3 .matches [0 ] != x {
175- t .Error ("s3 match mismatch" )
176- }
177- s4 , ok := v .valueTransitions [`"3"` ]
178- if ! ok {
179- t .Error (`no trans on "3" at s4` )
180- }
181- if len (s4 .transitions ) != 0 {
182- t .Errorf ("len trans s4 = %d" , len (s4 .transitions ))
183- }
184- if len (s4 .matches ) != 1 {
185- t .Errorf ("s4 matches %d" , len (s4 .matches ))
186- }
187- if s4 .matches [0 ] != x {
188- t .Error ("s4 match mismatch" )
189- }
190- }
135+ // TODO: Consider hand-checking the smallValueMacher structure
191136}
0 commit comments