@@ -1093,27 +1093,23 @@ func TestEmptyCaptureLargeRepeat(t *testing.T) {
10931093 }
10941094}
10951095
1096- func TestFuzzBytes (t * testing.T ) {
1096+ func TestFuzzBytes_NoCompile (t * testing.T ) {
10971097 //some crash cases found from fuzzing
10981098
10991099 var testCases = []struct {
1100- r , s []byte
1100+ r []byte
11011101 }{
11021102 {
11031103 r : []byte {0x28 , 0x28 , 0x29 , 0x5c , 0x37 , 0x28 , 0x3f , 0x28 , 0x29 , 0x29 },
1104- s : []byte {0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 },
11051104 },
11061105 {
11071106 r : []byte {0x28 , 0x5c , 0x32 , 0x28 , 0x3f , 0x28 , 0x30 , 0x29 , 0x29 },
1108- s : []byte {0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 },
11091107 },
11101108 {
11111109 r : []byte {0x28 , 0x3f , 0x28 , 0x29 , 0x29 , 0x5c , 0x31 , 0x30 , 0x28 , 0x3f , 0x28 , 0x30 , 0x29 },
1112- s : []byte {0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 },
11131110 },
11141111 {
11151112 r : []byte {0x28 , 0x29 , 0x28 , 0x28 , 0x29 , 0x5c , 0x37 , 0x28 , 0x3f , 0x28 , 0x29 , 0x29 },
1116- s : []byte {0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 },
11171113 },
11181114 }
11191115
@@ -1129,3 +1125,32 @@ func TestFuzzBytes(t *testing.T) {
11291125 }
11301126
11311127}
1128+
1129+ func TestFuzzBytes_Match (t * testing.T ) {
1130+
1131+ var testCases = []struct {
1132+ r , s []byte
1133+ }{
1134+ {
1135+ r : []byte {0x30 , 0xbf , 0x30 , 0x2a , 0x30 , 0x30 },
1136+ s : []byte {0xf0 , 0xb0 , 0x80 , 0x91 , 0xf7 },
1137+ },
1138+ {
1139+ r : []byte {0x30 , 0xaf , 0xf3 , 0x30 , 0x2a },
1140+ s : []byte {0xf3 , 0x80 , 0x80 , 0x87 , 0x80 , 0x89 },
1141+ },
1142+ }
1143+
1144+ for _ , c := range testCases {
1145+ r := string (c .r )
1146+ t .Run (r , func (t * testing.T ) {
1147+ re , err := Compile (r , 0 )
1148+
1149+ if err != nil {
1150+ t .Fatal ("should compile, but didn't" )
1151+ }
1152+
1153+ re .MatchString (string (c .s ))
1154+ })
1155+ }
1156+ }
0 commit comments