gitee.com/gricks/utils@v1.0.8/power_test.go (about) 1 package utils 2 3 import ( 4 "testing" 5 6 . "github.com/smartystreets/goconvey/convey" 7 ) 8 9 func Test_Power(t *testing.T) { 10 Convey("Power", t, func() { 11 So(LogRange(1, 300), ShouldResemble, []int{ 12 1, 2, 4, 8, 16, 32, 64, 128, 256}) 13 14 So(Ceilp2(1023), ShouldEqual, 1024) 15 So(Ceilp2(1024), ShouldEqual, 1024) 16 So(Ceilp2(1025), ShouldEqual, 2048) 17 18 So(Floorp2(1023), ShouldEqual, 512) 19 So(Floorp2(1024), ShouldEqual, 1024) 20 So(Floorp2(1025), ShouldEqual, 1024) 21 }) 22 }