|
| 1 | +import { describe, expect, test } from '@jest/globals'; |
| 2 | + |
| 3 | +import { bigIntMax, bigIntMin } from '../../utils/bigInt.js'; |
| 4 | + |
| 5 | +describe('bigIntMax', () => { |
| 6 | + test('returns maximum value from multiple positive bigints', () => { |
| 7 | + expect(bigIntMax(1n, 5n, 3n, 9n, 2n)).toBe(9n); |
| 8 | + }); |
| 9 | + |
| 10 | + test('returns maximum value from multiple negative bigints', () => { |
| 11 | + expect(bigIntMax(-10n, -5n, -20n, -1n)).toBe(-1n); |
| 12 | + }); |
| 13 | + |
| 14 | + test('returns maximum value from mixed positive and negative bigints', () => { |
| 15 | + expect(bigIntMax(-5n, 10n, -20n, 3n, -1n)).toBe(10n); |
| 16 | + }); |
| 17 | + |
| 18 | + test('returns the single value when only one argument is provided', () => { |
| 19 | + expect(bigIntMax(42n)).toBe(42n); |
| 20 | + }); |
| 21 | + |
| 22 | + test('returns correct value when all values are equal', () => { |
| 23 | + expect(bigIntMax(5n, 5n, 5n)).toBe(5n); |
| 24 | + }); |
| 25 | + |
| 26 | + test('handles very large bigint values', () => { |
| 27 | + const largeValue = 999999999999999999999999999999n; |
| 28 | + const smallerValue = 999999999999999999999999999998n; |
| 29 | + expect(bigIntMax(smallerValue, largeValue)).toBe(largeValue); |
| 30 | + }); |
| 31 | + |
| 32 | + test('returns zero when comparing zero with negative values', () => { |
| 33 | + expect(bigIntMax(0n, -5n, -10n)).toBe(0n); |
| 34 | + }); |
| 35 | + |
| 36 | + test('handles two values correctly', () => { |
| 37 | + expect(bigIntMax(100n, 200n)).toBe(200n); |
| 38 | + expect(bigIntMax(200n, 100n)).toBe(200n); |
| 39 | + }); |
| 40 | +}); |
| 41 | + |
| 42 | +describe('bigIntMin', () => { |
| 43 | + test('returns minimum value from multiple positive bigints', () => { |
| 44 | + expect(bigIntMin(1n, 5n, 3n, 9n, 2n)).toBe(1n); |
| 45 | + }); |
| 46 | + |
| 47 | + test('returns minimum value from multiple negative bigints', () => { |
| 48 | + expect(bigIntMin(-10n, -5n, -20n, -1n)).toBe(-20n); |
| 49 | + }); |
| 50 | + |
| 51 | + test('returns minimum value from mixed positive and negative bigints', () => { |
| 52 | + expect(bigIntMin(-5n, 10n, -20n, 3n, -1n)).toBe(-20n); |
| 53 | + }); |
| 54 | + |
| 55 | + test('returns the single value when only one argument is provided', () => { |
| 56 | + expect(bigIntMin(42n)).toBe(42n); |
| 57 | + }); |
| 58 | + |
| 59 | + test('returns correct value when all values are equal', () => { |
| 60 | + expect(bigIntMin(5n, 5n, 5n)).toBe(5n); |
| 61 | + }); |
| 62 | + |
| 63 | + test('handles very large bigint values', () => { |
| 64 | + const largeValue = 999999999999999999999999999999n; |
| 65 | + const smallerValue = 999999999999999999999999999998n; |
| 66 | + expect(bigIntMin(smallerValue, largeValue)).toBe(smallerValue); |
| 67 | + }); |
| 68 | + |
| 69 | + test('returns negative value when comparing zero with negative values', () => { |
| 70 | + expect(bigIntMin(0n, -5n, -10n)).toBe(-10n); |
| 71 | + }); |
| 72 | + |
| 73 | + test('handles two values correctly', () => { |
| 74 | + expect(bigIntMin(100n, 200n)).toBe(100n); |
| 75 | + expect(bigIntMin(200n, 100n)).toBe(100n); |
| 76 | + }); |
| 77 | +}); |
0 commit comments