Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_value_0_filetest.gno

2.18 Kb ยท 101 lines
  1package main
  2
  3import (
  4	"errors"
  5	"strings"
  6
  7	"gno.land/p/jeronimoalbi/expect"
  8)
  9
 10var (
 11	output strings.Builder
 12	t      = expect.MockTestingT(&output)
 13)
 14
 15type stringer string
 16
 17func (s stringer) String() string { return string(s) }
 18
 19func main() {
 20	expect.Value(t, "foo").ToEqual("bar")
 21	expect.Value(t, []byte("foo")).ToEqual([]byte("bar"))
 22	expect.Value(t, stringer("foo")).ToEqual(stringer("bar"))
 23	expect.Value(t, true).ToEqual(false)
 24	expect.Value(t, float32(1)).ToEqual(float32(2))
 25	expect.Value(t, float64(1.1)).ToEqual(float64(1.2))
 26	expect.Value(t, uint(1)).ToEqual(uint(2))
 27	expect.Value(t, uint8(1)).ToEqual(uint8(2))
 28	expect.Value(t, uint16(1)).ToEqual(uint16(2))
 29	expect.Value(t, uint32(1)).ToEqual(uint32(2))
 30	expect.Value(t, uint64(1)).ToEqual(uint64(2))
 31	expect.Value(t, int(1)).ToEqual(int(2))
 32	expect.Value(t, int8(1)).ToEqual(int8(2))
 33	expect.Value(t, int16(1)).ToEqual(int16(2))
 34	expect.Value(t, int32(1)).ToEqual(int32(2))
 35	expect.Value(t, int64(1)).ToEqual(int64(2))
 36	expect.Value(t, errors.New("foo")).ToEqual(errors.New("bar"))
 37	expect.Value(t, errors.New("foo")).ToContainErrorString("bar")
 38
 39	expect.Value(t, 0).ToEqual(errors.New("foo"))
 40	expect.Value(t, 0).ToEqual([]string{})
 41
 42	println(output.String())
 43}
 44
 45// Output:
 46// Expected values to match
 47// Got: foo
 48// Want: bar
 49// Expected values to match
 50// Got: foo
 51// Want: bar
 52// Expected values to match
 53// Got: foo
 54// Want: bar
 55// Expected values to match
 56// Got: true
 57// Want: false
 58// Expected values to match
 59// Got: 1
 60// Want: 2
 61// Expected values to match
 62// Got: 1.1
 63// Want: 1.2
 64// Expected values to match
 65// Got: 1
 66// Want: 2
 67// Expected values to match
 68// Got: 1
 69// Want: 2
 70// Expected values to match
 71// Got: 1
 72// Want: 2
 73// Expected values to match
 74// Got: 1
 75// Want: 2
 76// Expected values to match
 77// Got: 1
 78// Want: 2
 79// Expected values to match
 80// Got: 1
 81// Want: 2
 82// Expected values to match
 83// Got: 1
 84// Want: 2
 85// Expected values to match
 86// Got: 1
 87// Want: 2
 88// Expected values to match
 89// Got: 1
 90// Want: 2
 91// Expected values to match
 92// Got: 1
 93// Want: 2
 94// Expected errors to match
 95// Got: foo
 96// Want: bar
 97// Expected error message to contain: bar
 98// Got: foo
 99// Error is not equal to value
100// Got: foo
101// Unsupported type: unknown