MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / getTestsForPowerOfTwo

Function getTestsForPowerOfTwo

math/binary/checkisnumberpoweroftwo_test.go:14–36  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12)
13
14func getTestsForPowerOfTwo() []struct {
15 name string
16 a int
17 missing bool
18} {
19 var tests = []struct {
20 name string
21 a int
22 missing bool
23 }{
24 {"Is 64 a power of 2? - YES", 64, true},
25 {"Is 1 a power of 2? - YES", 1, true},
26 {"Is 2 a power of 2? - YES", 2, true},
27 {"Is 5 a power of 2? - NO", 5, false},
28 {"Is 1023 a power of 2? - NO", 1023, false},
29 {"Is 1024 a power of 2? - YES", 1024, true},
30 {"Is 0 a power of 2? - NO", 0, false},
31 {"Is 9223372036854775807 a power of 2? - NO", math.MaxInt64, false},
32 {"Is 9223372036854775806 a power of 2? - NO", math.MaxInt64, false},
33 {"Is 4611686018427387904 a power of 2? - YES", 4611686018427387904, true},
34 }
35 return tests
36}
37
38func TestIsPowerOfTwo(t *testing.T) {
39 tests := getTestsForPowerOfTwo()

Callers 3

TestIsPowerOfTwoFunction · 0.70
TestIsPowOfTwoUseLogFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected