MCPcopy
hub / github.com/NVIDIA/aistore / TestFastLog2

Function TestFastLog2

cmn/tests/math_test.go:15–35  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestFastLog2(t *testing.T) {
16 log22 := cos.FastLog2(2)
17 log42 := cos.FastLog2(4)
18 log82 := cos.FastLog2(8)
19 log10242 := cos.FastLog2(1024)
20 tassert.Fatalf(t, log22 == 1, "wrong power of 2 log2 result; got %d, expected %d", log22, 1)
21 tassert.Fatalf(t, log42 == 2, "wrong power of 2 log2 result; got %d, expected %d", log42, 2)
22 tassert.Fatalf(t, log82 == 3, "wrong power of 2 log2 result; got %d, expected %d", log82, 3)
23 tassert.Fatalf(t, log10242 == 10, "wrong power of 2 log2 result; got %d, expected %d", log10242, 10)
24
25 log32 := cos.FastLog2(3)
26 log52 := cos.FastLog2(5)
27 log152 := cos.FastLog2(15)
28 log10232 := cos.FastLog2(1023)
29 log10252 := cos.FastLog2(1025)
30 tassert.Fatalf(t, log32 == 1, "wrong log2 result; got %d, expected %d", log32, 1)
31 tassert.Fatalf(t, log52 == 2, "wrong log2 result; got %d, expected %d", log52, 2)
32 tassert.Fatalf(t, log152 == 3, "wrong log2 result; got %d, expected %d", log152, 3)
33 tassert.Fatalf(t, log10232 == 9, "wrong log2 result; got %d, expected %d", log10232, 9)
34 tassert.Fatalf(t, log10252 == 10, "wrong log2 result; got %d, expected %d", log10252, 10)
35}
36
37func TestFastLog2Ceil(t *testing.T) {
38 log22 := cos.FastLog2(2)

Callers

nothing calls this directly

Calls 2

FastLog2Function · 0.92
FatalfFunction · 0.92

Tested by

no test coverage detected