1package main
2
3// SEND: 200000000ugnot
4
5import (
6 "strconv"
7
8 "gno.land/r/demo/users"
9)
10
11func main() {
12 users.Register("", "alicia", "my profile")
13
14 {
15 // Normal usage
16 names := users.ListUsersByPrefix("a", 1)
17 println("# names: " + strconv.Itoa(len(names)))
18 println("name: " + names[0])
19 }
20
21 {
22 // Empty prefix: match all
23 names := users.ListUsersByPrefix("", 1)
24 println("# names: " + strconv.Itoa(len(names)))
25 println("name: " + names[0])
26 }
27
28 {
29 // The prefix is before "alicia"
30 names := users.ListUsersByPrefix("alich", 1)
31 println("# names: " + strconv.Itoa(len(names)))
32 }
33
34 {
35 // The prefix is after the last name
36 names := users.ListUsersByPrefix("y", 10)
37 println("# names: " + strconv.Itoa(len(names)))
38 }
39
40 // More tests are in p/demo/avlhelpers
41}
42
43// Output:
44// # names: 1
45// name: alicia
46// # names: 1
47// name: alicia
48// # names: 0
49// # names: 0
z_12_filetest.gno
0.86 Kb ยท 49 lines