Testing Bitwise Multiplication Implementation in javascript-algorithms
This test suite validates the multiplyByTwo function which performs binary multiplication by two using bitwise operations. The tests verify that the function correctly doubles integer inputs through bit shifting rather than traditional arithmetic multiplication.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
trekhleb/javascript-algorithms
src/algorithms/math/bits/__test__/multiplyByTwo.test.js
import multiplyByTwo from '../multiplyByTwo';
describe('multiplyByTwo', () => {
it('should multiply numbers by two using bitwise operations', () => {
expect(multiplyByTwo(0)).toBe(0);
expect(multiplyByTwo(1)).toBe(2);
expect(multiplyByTwo(3)).toBe(6);
expect(multiplyByTwo(10)).toBe(20);
expect(multiplyByTwo(17)).toBe(34);
expect(multiplyByTwo(125)).toBe(250);
});
});