Skip to content

Commit

Permalink
Implement unit tests for the numberToString utility function
Browse files Browse the repository at this point in the history
  • Loading branch information
timvandermeij committed Jan 14, 2023
1 parent a6dfcc8 commit 9e3adb5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/unit/core_utils_spec.js
Expand Up @@ -22,6 +22,7 @@ import {
isAscii,
isWhiteSpace,
log2,
numberToString,
parseXFAPath,
recoverJsURL,
stringToUTF16HexString,
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 9e3adb5

Please sign in to comment.