1package gnoface
2
3import (
4 "testing"
5
6 "gno.land/p/demo/uassert"
7 "gno.land/p/demo/ufmt"
8)
9
10func TestDraw(t *testing.T) {
11 cases := []struct {
12 seed uint64
13 expected string
14 }{
15 {
16 seed: 42,
17 expected: `
18 |||||||
19 |||||||||
20 | |
21 | . ~ |
22)| v v |O
23 | |
24 | L |
25 | |
26 | ___ |
27 | |
28 \~~~~~~~/
29`[1:],
30 },
31 {
32 seed: 1337,
33 expected: `
34 .......
35 |||||||||
36 | |
37 | . _ |
38D| x X |O
39 | |
40 | ~ |
41 | |
42 | ~~~ |
43 | |
44 \~~~~~~~/
45`[1:],
46 },
47 {
48 seed: 123456789,
49 expected: `
50 .......
51 ////////\
52 | |
53 | ~ * |
54|| x X |o
55 | |
56 | V |
57 | |
58 | . |
59 | |
60 \-------/
61`[1:],
62 },
63 }
64 for _, tc := range cases {
65 name := ufmt.Sprintf("%d", tc.seed)
66 t.Run(name, func(t *testing.T) {
67 got := Draw(tc.seed)
68 uassert.Equal(t, string(tc.expected), got)
69 })
70 }
71}
72
73func TestRender(t *testing.T) {
74 cases := []struct {
75 path string
76 expected string
77 }{
78 {
79 path: "42",
80 expected: "Gnoface #42\n```" + `
81 |||||||
82 |||||||||
83 | |
84 | . ~ |
85)| v v |O
86 | |
87 | L |
88 | |
89 | ___ |
90 | |
91 \~~~~~~~/
92` + "```\n",
93 },
94 {
95 path: "1337",
96 expected: "Gnoface #1337\n```" + `
97 .......
98 |||||||||
99 | |
100 | . _ |
101D| x X |O
102 | |
103 | ~ |
104 | |
105 | ~~~ |
106 | |
107 \~~~~~~~/
108` + "```\n",
109 },
110 {
111 path: "123456789",
112 expected: "Gnoface #123456789\n```" + `
113 .......
114 ////////\
115 | |
116 | ~ * |
117|| x X |o
118 | |
119 | V |
120 | |
121 | . |
122 | |
123 \-------/
124` + "```\n",
125 },
126 }
127 for _, tc := range cases {
128 t.Run(tc.path, func(t *testing.T) {
129 got := Render(tc.path)
130 uassert.Equal(t, tc.expected, got)
131 })
132 }
133}
gnoface_test.gno
1.67 Kb ยท 133 lines