File tree Expand file tree Collapse file tree 1 file changed +11
-22
lines changed
Expand file tree Collapse file tree 1 file changed +11
-22
lines changed Original file line number Diff line number Diff line change 11package be
22
33import (
4- "bytes"
5- "reflect"
6- "strings"
4+ "regexp"
75 "testing"
86)
97
108// In calls t.Fatalf if needle is not contained in the string or []byte haystack.
9+ //
10+ // Deprecated: Use Match(t, regexp.QuoteMeta(needle), haystack).
11+ //
12+ //go:fix inline
1113func In [byteseq ~ string | ~ []byte ](t testing.TB , needle string , haystack byteseq ) {
12- t .Helper ()
13- if ! in (needle , haystack ) {
14- t .Fatalf ("%q not in %q" , needle , haystack )
15- }
14+ Match (t , regexp .QuoteMeta (needle ), haystack )
1615}
1716
1817// NotIn calls t.Fatalf if needle is contained in the string or []byte haystack.
18+ //
19+ // Deprecated: Use NoMatch(t, regexp.QuoteMeta(needle), haystack).
20+ //
21+ //go:fix inline
1922func NotIn [byteseq ~ string | ~ []byte ](t testing.TB , needle string , haystack byteseq ) {
20- t .Helper ()
21- if in (needle , haystack ) {
22- t .Fatalf ("%q in %q" , needle , haystack )
23- }
24- }
25-
26- func in [byteseq ~ string | ~ []byte ](needle string , haystack byteseq ) bool {
27- rv := reflect .ValueOf (haystack )
28- switch rv .Kind () {
29- case reflect .String :
30- return strings .Contains (rv .String (), needle )
31- case reflect .Slice :
32- return bytes .Contains (rv .Bytes (), []byte (needle ))
33- }
34- panic ("unreachable" )
23+ NoMatch (t , regexp .QuoteMeta (needle ), haystack )
3524}
You can’t perform that action at this time.
0 commit comments