Implement unit tests for the numberToString utility function

This commit is contained in:
Tim van der Meij 2023-01-08 14:49:20 +01:00
parent a6dfcc89fa
commit 9e3adb5ec7
No known key found for this signature in database
GPG Key ID: 8C3FD2925A5F2762

View File

@ -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);