UNPKG

dist-javascript-algorithms-and-data-structures

Version:

Algorithms and data-structures implemented on JavaScript

24 lines (18 loc) 809 B
"use strict"; var _getBit = _interopRequireDefault(require("../getBit")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } describe('getBit', () => { it('should get bit at specific position', () => { // 1 = 0b0001 expect((0, _getBit.default)(1, 0)).toBe(1); expect((0, _getBit.default)(1, 1)).toBe(0); // 2 = 0b0010 expect((0, _getBit.default)(2, 0)).toBe(0); expect((0, _getBit.default)(2, 1)).toBe(1); // 3 = 0b0011 expect((0, _getBit.default)(3, 0)).toBe(1); expect((0, _getBit.default)(3, 1)).toBe(1); // 10 = 0b1010 expect((0, _getBit.default)(10, 0)).toBe(0); expect((0, _getBit.default)(10, 1)).toBe(1); expect((0, _getBit.default)(10, 2)).toBe(0); expect((0, _getBit.default)(10, 3)).toBe(1); }); });