github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/examples/gno.land/p/demo/groups/z_1_filetest.gno (about)

     1  // PKGPATH: gno.land/r/groups_test
     2  package groups_test
     3  
     4  import (
     5  	"gno.land/p/demo/groups"
     6  	"gno.land/p/demo/testutils"
     7  )
     8  
     9  var vset groups.VoteSet
    10  
    11  func init() {
    12  	addr1 := testutils.TestAddress("test1")
    13  	addr2 := testutils.TestAddress("test2")
    14  	vset = groups.NewVoteList()
    15  	vset.SetVote(addr1, "yes")
    16  	vset.SetVote(addr2, "yes")
    17  }
    18  
    19  func main() {
    20  	println(vset.Size())
    21  	println("yes:", vset.CountVotes("yes"))
    22  	println("no:", vset.CountVotes("no"))
    23  }
    24  
    25  // Output:
    26  // 2
    27  // yes: 2
    28  // no: 0