Files
bjarneo--cliamp/ipc/process_windows_test.go
wehub-resource-sync ead81af521
CI / go (push) Waiting to run
CI / build (darwin, macos-14) (push) Waiting to run
CI / build (windows, windows-2025) (push) Waiting to run
Deploy to GitHub Pages / deploy (push) Failing after 0s
chore: import upstream snapshot with attribution
2026-07-13 12:31:13 +08:00

35 lines
683 B
Go

//go:build windows
package ipc
import (
"math"
"os"
"testing"
)
func TestProcessAlive(t *testing.T) {
tests := []struct {
name string
pid int
want bool
}{
{name: "negative pid", pid: -1, want: false},
{name: "zero pid", pid: 0, want: false},
{name: "current process", pid: os.Getpid(), want: true},
{name: "unlikely pid", pid: math.MaxInt32, want: false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := processAlive(tt.pid)
if err != nil {
t.Fatalf("processAlive(%d) unexpected error: %v", tt.pid, err)
}
if got != tt.want {
t.Fatalf("processAlive(%d) = %v, want %v", tt.pid, got, tt.want)
}
})
}
}