@@ -1093,27 +1093,23 @@ func TestEmptyCaptureLargeRepeat(t *testing.T) {
1093
1093
}
1094
1094
}
1095
1095
1096
- func TestFuzzBytes (t * testing.T ) {
1096
+ func TestFuzzBytes_NoCompile (t * testing.T ) {
1097
1097
//some crash cases found from fuzzing
1098
1098
1099
1099
var testCases = []struct {
1100
- r , s []byte
1100
+ r []byte
1101
1101
}{
1102
1102
{
1103
1103
r : []byte {0x28 , 0x28 , 0x29 , 0x5c , 0x37 , 0x28 , 0x3f , 0x28 , 0x29 , 0x29 },
1104
- s : []byte {0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 },
1105
1104
},
1106
1105
{
1107
1106
r : []byte {0x28 , 0x5c , 0x32 , 0x28 , 0x3f , 0x28 , 0x30 , 0x29 , 0x29 },
1108
- s : []byte {0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 },
1109
1107
},
1110
1108
{
1111
1109
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 },
1113
1110
},
1114
1111
{
1115
1112
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 },
1117
1113
},
1118
1114
}
1119
1115
@@ -1129,3 +1125,32 @@ func TestFuzzBytes(t *testing.T) {
1129
1125
}
1130
1126
1131
1127
}
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