MCPcopy Index your code
hub / github.com/bitfield/script / TestRejectRegexp_DropsMatchingLinesFromInput

Function TestRejectRegexp_DropsMatchingLinesFromInput

script_test.go:1135–1167  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1133}
1134
1135func TestRejectRegexp_DropsMatchingLinesFromInput(t *testing.T) {
1136 t.Parallel()
1137 input := "hello world"
1138 tcs := []struct {
1139 regex, want string
1140 }{
1141 {
1142 regex: `Hello|line`,
1143 want: "hello world\n",
1144 },
1145 {
1146 regex: `hello|bogus`,
1147 want: "",
1148 },
1149 {
1150 regex: `w.*d`,
1151 want: "",
1152 },
1153 {
1154 regex: "wontmatch",
1155 want: "hello world\n",
1156 },
1157 }
1158 for _, tc := range tcs {
1159 got, err := script.Echo(input).RejectRegexp(regexp.MustCompile(tc.regex)).String()
1160 if err != nil {
1161 t.Fatal(err)
1162 }
1163 if tc.want != got {
1164 t.Error(cmp.Diff(tc.want, got))
1165 }
1166 }
1167}
1168
1169func TestSHA256Sums_OutputsCorrectHashForEachSpecifiedFile(t *testing.T) {
1170 t.Parallel()

Callers

nothing calls this directly

Calls 4

EchoFunction · 0.92
StringMethod · 0.80
RejectRegexpMethod · 0.80
ErrorMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…