func TestRegexFilterModifyResponse(t *testing.T) {
	tt := []struct {
		want   bool
		match  string
		regstr string
	}{
		{
			match:  "https://www.example.com",
			regstr: ".*www.example.com.*",
			want:   true,
		},
		{
			match:  "http://www.martian.external",
			regstr: ".*www.martian.local.*",
			want:   false,
		},
	}
	for i, tc := range tt {
		req, err := http.NewRequest("GET", tc.match, nil)
		if err != nil {
			t.Fatalf("%d. NewRequest(): got %v, want no error", i, err)
		}
		res := proxyutil.NewResponse(200, nil, req)
		regex, err := regexp.Compile(tc.regstr)
		if err != nil {
			t.Fatalf("%d. regexp.Compile(): got %v, want no error", i, err)
		}
		var modRun bool
		mod := NewRegexFilter(regex)
		mod.SetResponseModifier(martian.ResponseModifierFunc(
			func(*http.Response) error {
				modRun = true
				return nil
			}))
		if err := mod.ModifyResponse(res); err != nil {
			t.Fatalf("%d. ModifyResponse(): got %q, want no error", i, err)
		}
		if modRun != tc.want {
			t.Errorf("%d. modRun: got %t, want %t", i, modRun, tc.want)
		}
	}
}
The matching functionality is already tested above, so this just tests response setting.
package martianurl
import (
	"net/http"
	"regexp"
	"testing"
	"github.com/google/martian/v3"
	_ "github.com/google/martian/v3/header"
	"github.com/google/martian/v3/parse"
	"github.com/google/martian/v3/proxyutil"
)
func TestRegexFilterModifyRequest(t *testing.T) {
	tt := []struct {
		want   bool
		match  string
		regstr string
	}{
		{
			match:  "https://www.example.com",
			regstr: "https://.*",
			want:   true,
		},
		{
			match:  "http://www.example.com/subpath",
			regstr: ".*www.example.com.*",
			want:   true,
		},
		{
			match:  "https://www.example.com/subpath",
			regstr: ".*www.example.com.*",
			want:   true,
		},
		{
			match:  "http://www.example.com/test",
			regstr: ".*/test",
			want:   true,
		},
		{
			match:  "http://www.example.com?test=true",
			regstr: ".*test=true.*",
			want:   true,
		},
		{
			match:  "http://www.example.com#test",
			regstr: ".*test.*",
			want:   true,
		},
		{
			match:  "https://martian.local/test?test=true#test",
			regstr: "https://martian.local/test\\?test=true#test",
			want:   true,
		},
		{
			match:  "http://www.youtube.com/get_tags?tagone=yes",
			regstr: ".*www.youtube.com/get_tags\\?.*",
			want:   true,
		},
		{
			match:  "https://www.example.com",
			regstr: "http://.*",
			want:   false,
		},
		{
			match:  "http://www.martian.external",
			regstr: ".*www.martian.local.*",
			want:   false,
		},
		{
			match:  "http://www.example.com/testing",
			regstr: ".*/test$",
			want:   false,
		},
		{
			match:  "http://www.example.com?test=false",
			regstr: ".*test=true.*",
			want:   false,
		},
		{
			match:  "http://www.example.com#test",
			regstr: ".*#testing.*",
			want:   false,
		},
		{
			match: "https://martian.local/test?test=true#test",
			regstr: "https://martian.local/test\\\\?test=true#test",
			want:   false,
		},
		{
			match:  "http://www.youtube.com/get_tags/nope",
			regstr: ".*www.youtube.com/get_ad_tags\\?.*",
			want:   false,
		},
	}
	for i, tc := range tt {
		req, err := http.NewRequest("GET", tc.match, nil)
		if err != nil {
			t.Fatalf("%d. NewRequest(): got %v, want no error", i, err)
		}
		regex, err := regexp.Compile(tc.regstr)
		if err != nil {
			t.Fatalf("%d. regexp.Compile(): got %v, want no error", i, err)
		}
		var modRun bool
		mod := NewRegexFilter(regex)
		mod.SetRequestModifier(martian.RequestModifierFunc(
			func(*http.Request) error {
				modRun = true
				return nil
			}))
		if err := mod.ModifyRequest(req); err != nil {
			t.Fatalf("%d. ModifyRequest(): got %q, want no error", i, err)
		}
		if modRun != tc.want {
			t.Errorf("%d. modRun: got %t, want %t", i, modRun, tc.want)
		}
	}
}