Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

erc1155_test.gno

0.68 Kb · 32 lines
 1package erc1155
 2
 3import (
 4	"testing"
 5
 6	"gno.land/p/nt/uassert/v0"
 7)
 8
 9func TestSplitBalKey(t *testing.T) {
10	cases := []struct {
11		key       string
12		wantOwner string
13		wantID    string
14	}{
15		{"g1abcxyz:0", "g1abcxyz", "0"},
16		{"g1abcxyz:42", "g1abcxyz", "42"},
17		{"g1def:1", "g1def", "1"},
18		{"noseparator", "noseparator", ""},
19	}
20	for _, tc := range cases {
21		owner, id := splitBalKey(tc.key)
22		uassert.Equal(t, tc.wantOwner, owner)
23		uassert.Equal(t, tc.wantID, id)
24	}
25}
26
27func TestKeyHelpers(t *testing.T) {
28	addr := address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5")
29	uassert.Equal(t, addr.String()+":7", balKey(addr, 7))
30	uassert.Equal(t, "7", supKey(7))
31	uassert.Equal(t, "0", supKey(0))
32}