2021-10-08 15:41:45 +05:30
|
|
|
import {IsPowerOfTwo} from '../IsPowerOfTwo'
|
|
|
|
|
|
|
|
|
|
test('Check if 0 is a power of 2 or not:', () => {
|
2021-10-08 21:20:21 +05:30
|
|
|
const res = IsPowerOfTwo(0)
|
|
|
|
|
expect(res).toBe(false)
|
|
|
|
|
})
|
|
|
|
|
|
2021-10-09 12:23:49 +02:00
|
|
|
test('Check if 1 is a power of 2 or not:', () => {
|
2021-10-08 21:20:21 +05:30
|
|
|
const res = IsPowerOfTwo(1)
|
2021-10-09 12:23:49 +02:00
|
|
|
expect(res).toBe(true)
|
2021-10-08 15:41:45 +05:30
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('Check if 4 is a power of 2 or not:', () => {
|
|
|
|
|
const res = IsPowerOfTwo(4)
|
|
|
|
|
expect(res).toBe(true)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('Check if 1024 is a power of 2 or not:', () => {
|
|
|
|
|
const res = IsPowerOfTwo(1024)
|
|
|
|
|
expect(res).toBe(true)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('Check if 1025 is a power of 2 or not:', () => {
|
|
|
|
|
const res = IsPowerOfTwo(1025)
|
|
|
|
|
expect(res).toBe(false)
|
|
|
|
|
})
|