|
| 1 | +import { hexadecimalToDecimal } from '../HexadecimalToDecimal.js' |
| 2 | + |
| 3 | +describe('hexadecimalToDecimal', () => { |
| 4 | + test("hexadecimalToDecimal('0') returns 0", () => { |
| 5 | + expect(hexadecimalToDecimal('0')).toBe(0) |
| 6 | + }) |
| 7 | + |
| 8 | + test("hexadecimalToDecimal('A') returns 10", () => { |
| 9 | + expect(hexadecimalToDecimal('A')).toBe(10) |
| 10 | + }) |
| 11 | + |
| 12 | + test("hexadecimalToDecimal('F') returns 15", () => { |
| 13 | + expect(hexadecimalToDecimal('F')).toBe(15) |
| 14 | + }) |
| 15 | + |
| 16 | + test("hexadecimalToDecimal('10') returns 16", () => { |
| 17 | + expect(hexadecimalToDecimal('10')).toBe(16) |
| 18 | + }) |
| 19 | + |
| 20 | + test("hexadecimalToDecimal('FF') returns 255", () => { |
| 21 | + expect(hexadecimalToDecimal('FF')).toBe(255) |
| 22 | + }) |
| 23 | + |
| 24 | + test("hexadecimalToDecimal('100') returns 256", () => { |
| 25 | + expect(hexadecimalToDecimal('100')).toBe(256) |
| 26 | + }) |
| 27 | + |
| 28 | + test("hexadecimalToDecimal lowercase 'ff' returns 255", () => { |
| 29 | + expect(hexadecimalToDecimal('ff')).toBe(255) |
| 30 | + }) |
| 31 | + |
| 32 | + test("hexadecimalToDecimal('1000') returns 4096", () => { |
| 33 | + expect(hexadecimalToDecimal('1000')).toBe(4096) |
| 34 | + }) |
| 35 | + |
| 36 | + test('throws TypeError for invalid hex string', () => { |
| 37 | + expect(() => hexadecimalToDecimal('GHI')).toThrow(TypeError) |
| 38 | + }) |
| 39 | + |
| 40 | + test('throws TypeError for empty string', () => { |
| 41 | + expect(() => hexadecimalToDecimal('')).toThrow(TypeError) |
| 42 | + }) |
| 43 | + |
| 44 | + test('throws TypeError for non-string input', () => { |
| 45 | + expect(() => hexadecimalToDecimal(255)).toThrow(TypeError) |
| 46 | + }) |
| 47 | +}) |
0 commit comments