package instance import "testing" func TestShouldKill(t *testing.T) { t.Parallel() const ( self uint32 = 10 selfPath = `C:\Users\me\Downloads\win64_mp.exe` installed = `C:\Users\me\AppData\Roaming\win64_mp\win64_mp.exe` ) cases := []struct { pid uint32 image string exeName string want bool }{ {self, selfPath, "win64_mp.exe", false}, {11, installed, "win64_mp.exe", true}, {11, `C:\Temp\win64_mp.exe`, "win64_mp.exe", true}, {11, "", "win64_mp.exe", true}, {11, `C:\Windows\System32\notepad.exe`, "notepad.exe", false}, {0, installed, "win64_mp.exe", false}, } for _, tc := range cases { got := shouldKill(self, tc.pid, selfPath, tc.image, installed, tc.exeName) if got != tc.want { t.Fatalf("shouldKill pid=%d image=%q name=%q = %v, want %v", tc.pid, tc.image, tc.exeName, got, tc.want) } } }