From 9e3adb5ec70f62ecc9dd7c2b3cb15a02286b3d45 Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Sun, 8 Jan 2023 14:49:20 +0100 Subject: [PATCH] Implement unit tests for the `numberToString` utility function --- test/unit/core_utils_spec.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/unit/core_utils_spec.js b/test/unit/core_utils_spec.js index 41a16a0ed..f8fb8da16 100644 --- a/test/unit/core_utils_spec.js +++ b/test/unit/core_utils_spec.js @@ -22,6 +22,7 @@ import { isAscii, isWhiteSpace, log2, + numberToString, parseXFAPath, recoverJsURL, stringToUTF16HexString, @@ -182,6 +183,21 @@ describe("core_utils", function () { }); }); + describe("numberToString", function () { + it("should stringify integers", function () { + expect(numberToString(1)).toEqual("1"); + expect(numberToString(0)).toEqual("0"); + expect(numberToString(-1)).toEqual("-1"); + }); + + it("should stringify floats", function () { + expect(numberToString(1.0)).toEqual("1"); + expect(numberToString(1.2)).toEqual("1.2"); + expect(numberToString(1.23)).toEqual("1.23"); + expect(numberToString(1.234)).toEqual("1.23"); + }); + }); + describe("isWhiteSpace", function () { it("handles space characters", function () { expect(isWhiteSpace(0x20)).toEqual(true);