...
1 package snapshot
2
3 import (
4 "errors"
5 "testing"
6 )
7
8 func TestPrimatives(t *testing.T) {
9 cases := map[string]any{
10 "string": "I am a snapshot.\nA string snapshot, to be sure.\nCan you read me now?",
11 "string-with-escapes": "strval\nwith\t\"escapes\"",
12 "bool": true,
13 "int": int(93),
14 "int8": int8(93),
15 "int16": int16(93),
16 "int32": int32(93),
17 "int64": int64(93),
18 "int-negative": int(-93),
19 "int8-negative": int8(-93),
20 "int16-negative": int16(-93),
21 "int32-negative": int32(-93),
22 "int64-negative": int64(-93),
23 "uint": uint(93),
24 "uint8": uint8(93),
25 "uint16": uint16(93),
26 "uint32": uint32(93),
27 "uint64": uint64(93),
28 "uintptr": uintptr(93),
29 "float32": float32(93.75),
30 "float64": float64(93.75),
31 "complex64": complex64(93i),
32 "complex128": complex128(93i),
33 "error": errors.New("I am an error"),
34 }
35
36 for test, tc := range cases {
37 t.Run(test, func(t *testing.T) {
38 Snap(t, tc)
39 })
40 }
41 }
42
View as plain text