github.com/TeaOSLab/EdgeNode@v1.3.8/internal/utils/maps/map_fixed_test.go (about)

     1  // Copyright 2023 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
     2  
     3  package maputils_test
     4  
     5  import (
     6  	maputils "github.com/TeaOSLab/EdgeNode/internal/utils/maps"
     7  	"testing"
     8  )
     9  
    10  func TestNewFixedMap(t *testing.T) {
    11  	var m = maputils.NewFixedMap[string, int](3)
    12  	m.Put("a", 1)
    13  	t.Log(m.RawMap())
    14  	t.Log(m.Get("a"))
    15  	t.Log(m.Get("b"))
    16  
    17  	m.Put("b", 2)
    18  	m.Put("c", 3)
    19  	t.Log(m.RawMap(), m.Keys())
    20  
    21  	m.Put("d", 4)
    22  	t.Log(m.RawMap(), m.Keys())
    23  
    24  	m.Put("b", 200)
    25  	t.Log(m.RawMap(), m.Keys())
    26  }