Testing Binary Bit Clearing Operations in javascript-algorithms
This test suite validates the clearBit function’s ability to manipulate binary numbers by clearing specific bit positions. It examines the function’s behavior with different input numbers and bit positions, ensuring accurate bit manipulation operations.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
trekhleb/javascript-algorithms
src/algorithms/math/bits/__test__/clearBit.test.js
import clearBit from '../clearBit';
describe('clearBit', () => {
it('should clear bit at specific position', () => {
// 1 = 0b0001
expect(clearBit(1, 0)).toBe(0);
expect(clearBit(1, 1)).toBe(1);
expect(clearBit(1, 2)).toBe(1);
// 10 = 0b1010
expect(clearBit(10, 0)).toBe(10);
expect(clearBit(10, 1)).toBe(8);
expect(clearBit(10, 3)).toBe(2);
});
});