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