@@ -106,7 +106,6 @@ func TestMaintainCaptureOrder_Enable_Inline(t *testing.T) {
106
106
}
107
107
text := "This is a \n testing stuff"
108
108
m , err := r .FindStringMatch (text )
109
- // t.Errorf(" groups: %#v\n", m)
110
109
if err != nil {
111
110
t .Errorf ("unexpected match err: %v" , err )
112
111
}
@@ -143,6 +142,35 @@ func TestMaintainCaptureOrder_Enable_Inline(t *testing.T) {
143
142
}
144
143
}
145
144
145
+ func TestMaintainCaptureOrder_Inline_No_Capture_Groups (t * testing.T ) {
146
+ r , err := Compile ("(?o)this.+?testing.+?stuff" , 0 )
147
+ // t.Logf("code dump: %v", r.code.Dump())
148
+ if err != nil {
149
+ t .Errorf ("unexpected compile err: %v" , err )
150
+ }
151
+ text := `this is a testing stuff`
152
+ m , err := r .FindStringMatch (text )
153
+ if err != nil {
154
+ t .Errorf ("unexpected match err: %v" , err )
155
+ }
156
+ if m == nil {
157
+ t .Error ("Nil match, expected success" )
158
+ } else {
159
+ //t.Logf("Match: %v", m.dump())
160
+ }
161
+
162
+ groups := m .Groups ()
163
+ if want , got := text , m .String (); want != got {
164
+ t .Fatalf ("Wanted '%v'\n Got '%v'" , want , got )
165
+ }
166
+ if want , got := text , groups [0 ].String (); want != got {
167
+ t .Fatalf ("Wanted '%v'\n Got '%v'" , want , got )
168
+ }
169
+ if want , got := 1 , len (groups ); want != got {
170
+ t .Fatalf ("Wanted '%v'\n Got '%v'" , want , got )
171
+ }
172
+ }
173
+
146
174
func TestMaintainCaptureOrder_NestedCaptures (t * testing.T ) {
147
175
r , err := Compile (
148
176
`(?<first>This)(?<second>(.)+?(?<test>testing)).+?(some.+?(other).+?(?<last>stuff)) (?<test>\k<test>)` , MaintainCaptureOrder )
0 commit comments