github.com/haraldrudell/parl@v0.4.176/pmaps/go-map-size_test.go (about)

     1  /*
     2  © 2023–present Harald Rudell <harald.rudell@gmail.com> (https://haraldrudell.github.io/haraldrudell/)
     3  ISC License
     4  */
     5  
     6  package pmaps
     7  
     8  import (
     9  	"testing"
    10  )
    11  
    12  func TestGoMapSize(t *testing.T) {
    13  	var nilSize = uint64(0)
    14  
    15  	var size uint64
    16  
    17  	var m map[int]int
    18  
    19  	// nil map
    20  	if size = GoMapSize(m); size != nilSize {
    21  		t.Error("nil map not size 0")
    22  	}
    23  
    24  	// map with more than 2 values
    25  	m = make(map[int]int, 3)
    26  	if size = GoMapSize(m); size == nilSize {
    27  		t.Error("map size 0")
    28  	}
    29  }