Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

id_test.gno

0.80 Kb · 27 lines
 1package boards_test
 2
 3import (
 4	"testing"
 5
 6	"gno.land/p/nt/urequire/v0"
 7
 8	"gno.land/p/gnoland/boards/v0"
 9)
10
11func TestID(t *testing.T) {
12	id := boards.ID(42)
13
14	urequire.Equal(t, "42", id.String(), "expect string to match")
15	urequire.Equal(t, "0000000042", id.PaddedString(), "expect padded string to match")
16	urequire.Equal(t, "000001a", id.Key(), "expect key to match")
17}
18
19func TestIdentifierGenerator(t *testing.T) {
20	g := boards.NewIdentifierGenerator()
21
22	urequire.Equal(t, uint64(0), uint64(g.Last()), "expect default to be 0")
23	urequire.Equal(t, uint64(1), uint64(g.Next()), "expect next to be 1")
24	urequire.Equal(t, uint64(1), uint64(g.Last()), "expect last to be 1")
25	urequire.Equal(t, uint64(2), uint64(g.Next()), "expect next to be 2")
26	urequire.Equal(t, uint64(2), uint64(g.Last()), "expect last to be 2")
27}