z_func_3_filetest.gno
1.15 Kb ยท 48 lines
1package main
2
3import (
4 "strings"
5
6 "gno.land/p/jeronimoalbi/expect"
7)
8
9var (
10 output strings.Builder
11 t = expect.MockTestingT(&output)
12)
13
14func main() {
15 msg := "Boom!"
16
17 expect.Func(t, func() { panic(msg) }).Not().ToPanic()
18 expect.Func(t, func() { panic(msg) }).ToPanic().Not().WithMessage(msg)
19
20 expect.Func(t, func() error { panic(msg) }).Not().ToPanic()
21 expect.Func(t, func() error { panic(msg) }).ToPanic().Not().WithMessage(msg)
22
23 expect.Func(t, func() any { panic(msg) }).Not().ToPanic()
24 expect.Func(t, func() any { panic(msg) }).ToPanic().Not().WithMessage(msg)
25
26 expect.Func(t, func() (any, error) { panic(msg) }).Not().ToPanic()
27 expect.Func(t, func() (any, error) { panic(msg) }).ToPanic().Not().WithMessage(msg)
28
29 println(output.String())
30}
31
32// Output:
33// Expected func not to panic
34// Got: Boom!
35// Expected panic message to be different
36// Got: Boom!
37// Expected func not to panic
38// Got: Boom!
39// Expected panic message to be different
40// Got: Boom!
41// Expected func not to panic
42// Got: Boom!
43// Expected panic message to be different
44// Got: Boom!
45// Expected func not to panic
46// Got: Boom!
47// Expected panic message to be different
48// Got: Boom!