feat(common): 添加无锁并发工具包依赖
新增 lockfree-1.1.3 工具包到 go.work 文件中,为项目提供无锁并发数据结构支持, 提升高并发场景下的性能表现。
This commit is contained in:
27
common/utils/lockfree-1.1.3/util_test.go
Normal file
27
common/utils/lockfree-1.1.3/util_test.go
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) THL A29 Limited, a Tencent company. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
*/
|
||||
|
||||
package lockfree
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestMinSuitableCap(t *testing.T) {
|
||||
x := minSuitableCap(-1)
|
||||
assert.Equal(t, 2, x)
|
||||
x = minSuitableCap(3)
|
||||
assert.Equal(t, 4, x)
|
||||
x = minSuitableCap(10)
|
||||
assert.Equal(t, 16, x)
|
||||
x = minSuitableCap(1023)
|
||||
assert.Equal(t, 1024, x)
|
||||
x = minSuitableCap(16)
|
||||
assert.Equal(t, 16, x)
|
||||
}
|
||||
Reference in New Issue
Block a user