diff --git a/assembly/__tests__/u128.spec.as.ts b/assembly/__tests__/u128.spec.as.ts index 842cbee..0e70ab3 100644 --- a/assembly/__tests__/u128.spec.as.ts +++ b/assembly/__tests__/u128.spec.as.ts @@ -5,26 +5,37 @@ describe("String Conversion", () => { it("Should convert to decimal string 1", () => { var a = new u128(10248516654965971928, 5); expect('102482237023513730008').toStrictEqual(a.toString()); + expect('58e3a0b9945ebdbd8').toStrictEqual(a.toString(16)); }); it("Should convert to decimal string 2", () => { var a = u128.Max; expect('340282366920938463463374607431768211455').toStrictEqual(a.toString()); + expect('ffffffffffffffffffffffffffffffff').toStrictEqual(a.toString(16)); }); it("Should convert to decimal string 3", () => { var a = u128.Zero; expect('0').toStrictEqual(a.toString()); + expect('0').toStrictEqual(a.toString(16)); }); it("Should convert to decimal string 4", () => { var a = u128.from(90); + expect('90').toStrictEqual(a.toString()); expect('5a').toStrictEqual(a.toString(16)); }); it("Should convert to decimal string 5", () => { - var a = u128.Max; - expect('ffffffffffffffffffffffffffffffff').toStrictEqual(a.toString(16)); + var a = new u128(u64.MAX_VALUE); + expect('18446744073709551615').toStrictEqual(a.toString()); + expect('ffffffffffffffff').toStrictEqual(a.toString(16)); + }); + + it("Should convert to decimal string 6", () => { + var a = new u128(u64.MAX_VALUE - 1, u64.MAX_VALUE - 1); + expect('340282366920938463444927863358058659838').toStrictEqual(a.toString()); + expect('fffffffffffffffefffffffffffffffe').toStrictEqual(a.toString(16)); }); it("Should convert from decimal string 1", () => { diff --git a/package.json b/package.json index 66b07d7..077b182 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "as-bignum", - "version": "0.2.19", + "version": "0.2.20", "description": "128 and 256 bits integer and fixed point arithmetics for AssemblyScript. Also support checking overflow/underflow", "main": "js/index.js", "types": "assembly/index.ts",