github.com/bruceshao/lockfree@v1.1.3-0.20230816090528-e89824c0a6e9/util_test.go (about) 1 /* 2 * Copyright (C) THL A29 Limited, a Tencent company. All rights reserved. 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 */ 7 8 package lockfree 9 10 import ( 11 "testing" 12 13 "github.com/stretchr/testify/assert" 14 ) 15 16 func TestMinSuitableCap(t *testing.T) { 17 x := minSuitableCap(-1) 18 assert.Equal(t, 2, x) 19 x = minSuitableCap(3) 20 assert.Equal(t, 4, x) 21 x = minSuitableCap(10) 22 assert.Equal(t, 16, x) 23 x = minSuitableCap(1023) 24 assert.Equal(t, 1024, x) 25 x = minSuitableCap(16) 26 assert.Equal(t, 16, x) 27 }