z_boolean_2_filetest.gno

1.01 Kb ยท 45 lines
 1package main
 2
 3import (
 4	"strconv"
 5	"strings"
 6
 7	"gno.land/p/jeronimoalbi/expect"
 8)
 9
10var (
11	output strings.Builder
12	t      = expect.MockTestingT(&output)
13)
14
15type intStringer struct{ value int }
16
17func (v intStringer) String() string {
18	return strconv.Itoa(v.value)
19}
20
21func main() {
22	expect.Value(t, false).AsBoolean().ToBeTruthy()
23	expect.Value(t, true).AsBoolean().Not().ToBeTruthy()
24
25	expect.Value(t, "FALSE").AsBoolean().ToBeTruthy()
26	expect.Value(t, "TRUE").AsBoolean().Not().ToBeTruthy()
27
28	expect.Value(t, []byte(nil)).AsBoolean().ToBeTruthy()
29	expect.Value(t, []byte("")).AsBoolean().Not().ToBeTruthy()
30
31	expect.Value(t, intStringer{0}).AsBoolean().ToBeTruthy()
32	expect.Value(t, intStringer{1}).AsBoolean().Not().ToBeTruthy()
33
34	println(output.String())
35}
36
37// Output:
38// Expected value to be truthy
39// Expected value not to be truthy
40// Expected value to be truthy
41// Expected value not to be truthy
42// Expected value to be truthy
43// Expected value not to be truthy
44// Expected value to be truthy
45// Expected value not to be truthy