@@ -7,77 +7,15 @@ import (
7
7
"gno.land/p/demo/uassert"
8
8
)
9
9
10
- type poolPathWithFeeDivideTestCases struct {
11
- name string
12
- input string
13
- wantToken0 string
14
- wantToken1 string
15
- wantFee int
16
- shouldPanic bool
17
- }
18
-
19
- func TestPoolPathWithFeeDivide(t *testing.T) {
20
- tests := []poolPathWithFeeDivideTestCases{
21
- {
22
- name: "valid path",
23
- input: "token0:token1:500",
24
- wantToken0: "token0",
25
- wantToken1: "token1",
26
- wantFee: 500,
27
- shouldPanic: false,
28
- },
29
- {
30
- name: "valid path with special characters",
31
- input: "r/token_a:r/token_b:3000",
32
- wantToken0: "r/token_a",
33
- wantToken1: "r/token_b",
34
- wantFee: 3000,
35
- shouldPanic: false,
36
- },
37
- {
38
- name: "invalid fee format",
39
- input: "token0:token1:abc",
40
- shouldPanic: true,
41
- },
42
- {
43
- name: "missing parts",
44
- input: "token0:token1",
45
- shouldPanic: true,
46
- },
47
- {
48
- name: "empty string",
49
- input: "",
50
- shouldPanic: true,
51
- },
52
- }
53
-
54
- for _, tt := range tests {
55
- t.Run(tt.name, func(t *testing.T) {
56
- defer func() {
57
- r := recover()
58
- if (r != nil) != tt.shouldPanic {
59
- t.Errorf("poolPathWithFeeDivide() panic = %v, shouldPanic = %v", r != nil, tt.shouldPanic)
60
- }
61
- }()
62
-
63
- token0, token1, fee := poolPathWithFeeDivide(tt.input)
64
- if !tt.shouldPanic {
65
- if token0 != tt.wantToken0 {
66
- t.Errorf("token0 = %v, want %v", token0, tt.wantToken0)
67
- }
68
- if token1 != tt.wantToken1 {
69
- t.Errorf("token1 = %v, want %v", token1, tt.wantToken1)
70
- }
71
- if fee != tt.wantFee {
72
- t.Errorf("fee = %v, want %v", fee, tt.wantFee)
73
- }
74
- }
75
- })
76
- }
77
- }
78
-
79
10
func TestGetDataForSinglePath(t *testing.T) {
80
- tests := []poolPathWithFeeDivideTestCases{
11
+ tests := []struct {
12
+ name string
13
+ input string
14
+ wantToken0 string
15
+ wantToken1 string
16
+ wantFee int
17
+ shouldPanic bool
18
+ }{
81
19
{
82
20
name: "valid path",
83
21
input: "tokenA:tokenB:500",
@@ -222,32 +160,32 @@ func TestSplitSingleChar(t *testing.T) {
222
160
expected: []string{"a", "b", "c"},
223
161
},
224
162
{
225
- name: "single character string",
226
- input: "a",
227
- sep: ',',
228
- expected: []string{"a"},
229
- },
230
- {
231
- name: "only separators",
232
- input: ",,,,",
233
- sep: ',',
234
- expected: []string{"", "", "", "", ""},
235
- },
236
- {
237
- name: "unicode characters",
238
- input: "한글,English,日本語",
239
- sep: ',',
240
- expected: []string{"한글", "English", "日本語"},
241
- },
242
- {
243
- name: "special characters",
244
- input: "!@#$,%^&*,()_+",
245
- sep: ',',
246
- expected: []string{"!@#$", "%^&*", "()_+"},
247
- },
163
+ name: "single character string",
164
+ input: "a",
165
+ sep: ',',
166
+ expected: []string{"a"},
167
+ },
168
+ {
169
+ name: "only separators",
170
+ input: ",,,,",
171
+ sep: ',',
172
+ expected: []string{"", "", "", "", ""},
173
+ },
174
+ {
175
+ name: "unicode characters",
176
+ input: "한글,English,日本語",
177
+ sep: ',',
178
+ expected: []string{"한글", "English", "日本語"},
179
+ },
180
+ {
181
+ name: "special characters",
182
+ input: "!@#$,%^&*,()_+",
183
+ sep: ',',
184
+ expected: []string{"!@#$", "%^&*", "()_+"},
185
+ },
248
186
{
249
- name: "routes path",
250
- input: "gno.land/r/onbloc/bar:gno.land/r/onbloc/baz:500*POOL*gno.land/r/onbloc/baz:gno.land/r/onbloc/qux:500,gno.land/r/onbloc/bar:gno.land/r/onbloc/baz:500*POOL*gno.land/r/onbloc/baz:gno.land/r/onbloc/qux:500",
187
+ name: "routes path",
188
+ input: "gno.land/r/onbloc/bar:gno.land/r/onbloc/baz:500*POOL*gno.land/r/onbloc/baz:gno.land/r/onbloc/qux:500,gno.land/r/onbloc/bar:gno.land/r/onbloc/baz:500*POOL*gno.land/r/onbloc/baz:gno.land/r/onbloc/qux:500",
251
189
sep: ',',
252
190
expected: []string{"gno.land/r/onbloc/bar:gno.land/r/onbloc/baz:500*POOL*gno.land/r/onbloc/baz:gno.land/r/onbloc/qux:500", "gno.land/r/onbloc/bar:gno.land/r/onbloc/baz:500*POOL*gno.land/r/onbloc/baz:gno.land/r/onbloc/qux:500"},
253
191
},
0 commit comments