github.com/tursom/GoCollections@v0.3.10/util/Context_test.go (about) 1 /* 2 * Copyright (c) 2022 tursom. All rights reserved. 3 * Use of this source code is governed by a GPL-3 4 * license that can be found in the LICENSE file. 5 */ 6 7 package util 8 9 import ( 10 "fmt" 11 "testing" 12 ) 13 14 func TestContextKey(t *testing.T) { 15 ctx := NewContext() 16 key := AllocateContextKey[int](ctx) 17 18 m := ctx.NewConcurrentMap() 19 20 fmt.Println(key.Get(m)) 21 fmt.Println(key.TryGet(m)) 22 23 key.Set(m, 100) 24 fmt.Println(key.Get(m)) 25 fmt.Println(key.TryGet(m)) 26 }