package core import ( "errors" "testing" ) func TestResultOk(t *testing.T) { r := Ok(42) if !r.IsOk() { t.Error("expected IsOk") } if r.IsErr() { t.Error("expected not IsErr") } if r.Unwrap() != 42 { t.Errorf("got %d, want 42", r.Unwrap()) } } func TestResultErr(t *testing.T) { r := Err[int](errors.New("fail")) if r.IsOk() { t.Error("expected not IsOk") } if !r.IsErr() { t.Error("expected IsErr") } if r.UnwrapErr().Error() != "fail" { t.Errorf("got %v", r.UnwrapErr()) } } func TestUnwrapOr(t *testing.T) { ok := Ok(10) if ok.UnwrapOr(0) != 10 { t.Error("UnwrapOr on Ok should return value") } err := Err[int](errors.New("fail")) if err.UnwrapOr(99) != 99 { t.Error("UnwrapOr on Err should return default") } } func TestUnwrapPanics(t *testing.T) { defer func() { if recover() == nil { t.Error("Unwrap on Err should panic") } }() Err[int](errors.New("fail")).Unwrap() }