Add isPowerOfTwo snippet
This commit is contained in:
29
test/isPowerOfTwo.test.js
Normal file
29
test/isPowerOfTwo.test.js
Normal file
@ -0,0 +1,29 @@
|
||||
const {isPowerOfTwo} = require('./_30s.js');
|
||||
|
||||
test('isPowerOfTwo is a Function', () => {
|
||||
expect(isPowerOfTwo).toBeInstanceOf(Function);
|
||||
});
|
||||
test('0 is not a power of 2', () => {
|
||||
expect(isPowerOfTwo(0)).toBeFalsy();
|
||||
});
|
||||
test('1 is a power of 2', () => {
|
||||
expect(isPowerOfTwo(1)).toBeTruthy();
|
||||
});
|
||||
test('2 is a power of 2', () => {
|
||||
expect(isPowerOfTwo(2)).toBeTruthy();
|
||||
});
|
||||
test('3 is not a power of 2', () => {
|
||||
expect(isPowerOfTwo(3)).toBeFalsy();
|
||||
});
|
||||
test('4 is a power of 2', () => {
|
||||
expect(isPowerOfTwo(4)).toBeTruthy();
|
||||
});
|
||||
test('5 is not a power of 2', () => {
|
||||
expect(isPowerOfTwo(5)).toBeFalsy();
|
||||
});
|
||||
test('6 is not a power of 2', () => {
|
||||
expect(isPowerOfTwo(6)).toBeFalsy();
|
||||
});
|
||||
test('undefined is not a power of 2', () => {
|
||||
expect(isPowerOfTwo()).toBeFalsy();
|
||||
});
|
||||
Reference in New Issue
Block a user