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

Function TestMatchOutputsOnlyMatchingLinesOfInput

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

Source from the content-addressed store, hash-verified

921}
922
923func TestMatchOutputsOnlyMatchingLinesOfInput(t *testing.T) {
924 t.Parallel()
925 input := "This is the first line in the file.\nHello, world.\nThis is another line in the file.\n"
926 tcs := []struct {
927 match, want string
928 }{
929 {
930 match: "line",
931 want: "This is the first line in the file.\nThis is another line in the file.\n",
932 },
933 {
934 match: "another",
935 want: "This is another line in the file.\n",
936 },
937 {
938 match: "definitely won't match any lines",
939 want: "",
940 },
941 }
942 for _, tc := range tcs {
943 got, err := script.Echo(input).Match(tc.match).String()
944 if err != nil {
945 t.Fatal(err)
946 }
947 if tc.want != got {
948 t.Error(cmp.Diff(tc.want, got))
949 }
950 }
951}
952
953func TestMatchOutputsNothingGivenEmptyInput(t *testing.T) {
954 t.Parallel()

Callers

nothing calls this directly

Calls 4

EchoFunction · 0.92
StringMethod · 0.80
MatchMethod · 0.80
ErrorMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…