From ae21501aa21319ad305b17c451e9d0907e134f1b Mon Sep 17 00:00:00 2001 From: David Lechner Date: Thu, 21 May 2020 20:39:57 -0500 Subject: [PATCH] test sumComplement32 --- src/utils/math.test.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/utils/math.test.ts b/src/utils/math.test.ts index 36c31a09..c0197710 100644 --- a/src/utils/math.test.ts +++ b/src/utils/math.test.ts @@ -1,4 +1,4 @@ -import { fmod } from './math'; +import { fmod, sumComplement32 } from './math'; test('fmod of positive numbers', () => { expect(fmod(3, 4)).toBe(3 % 4); @@ -7,3 +7,10 @@ test('fmod of positive numbers', () => { test('fmod of negative and positive number', () => { expect(fmod(-3, 4)).toBe(1); }); + +test('sumComplement32', () => { + // basic test + expect(sumComplement32([1, 2, 3, 4, 5])).toBe(-(1 + 2 + 3 + 4 + 5)); + // overflow + expect(sumComplement32([0xffffffff, 0xffffffff])).toBe(-(-1 + -1)); +});