github.com/neatio-net/neatio@v1.7.3-0.20231114194659-f4d7a2226baa/chain/core/vm/intpool_test.go (about) 1 package vm 2 3 import ( 4 "testing" 5 ) 6 7 func TestIntPoolPoolGet(t *testing.T) { 8 poolOfIntPools.pools = make([]*intPool, 0, poolDefaultCap) 9 10 nip := poolOfIntPools.get() 11 if nip == nil { 12 t.Fatalf("Invalid pool allocation") 13 } 14 } 15 16 func TestIntPoolPoolPut(t *testing.T) { 17 poolOfIntPools.pools = make([]*intPool, 0, poolDefaultCap) 18 19 nip := poolOfIntPools.get() 20 if len(poolOfIntPools.pools) != 0 { 21 t.Fatalf("Pool got added to list when none should have been") 22 } 23 24 poolOfIntPools.put(nip) 25 if len(poolOfIntPools.pools) == 0 { 26 t.Fatalf("Pool did not get added to list when one should have been") 27 } 28 } 29 30 func TestIntPoolPoolReUse(t *testing.T) { 31 poolOfIntPools.pools = make([]*intPool, 0, poolDefaultCap) 32 nip := poolOfIntPools.get() 33 poolOfIntPools.put(nip) 34 poolOfIntPools.get() 35 36 if len(poolOfIntPools.pools) != 0 { 37 t.Fatalf("Invalid number of pools. Got %d, expected %d", len(poolOfIntPools.pools), 0) 38 } 39 }