fix(Type): Scan method fixes

This commit is contained in:
2025-01-01 22:24:59 +01:00
parent b5fc0df93b
commit 864953076a
3 changed files with 136 additions and 87 deletions

View File

@@ -18,6 +18,20 @@ var (
nilOptional = (*Optional[int])(nil)
)
func Test_optionalScan(t *testing.T) {
a := None[string]()
b := None[*string]()
c := None[string]()
d := None[int]()
a.Scan("a")
b.Scan("b")
c.Scan(Ptr("c"))
Testing.AssertEqual(t, "a", a.Unwrap())
Testing.AssertEqual(t, "b", *b.Unwrap())
Testing.AssertEqual(t, "c", c.Unwrap())
Testing.AssertPanic(t, func() { d.Unwrap() })
}
func Test_optionalSome(t *testing.T) {
Testing.AssertEqual(t, x, y)
Testing.AssertEqual(t, v, u)