Skip to content

Commit 40ee9ae

Browse files
Update hanzi2num tests
1 parent d834f16 commit 40ee9ae

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

test/hanzi2num.test.js

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
var assert = require("assert");
2-
var { num2hanzi, hanzi2num } = require("../src/hanzi2num");
2+
var { num2hanzi, hanzi2num, hanzi2numstr } = require("../src/hanzi2num");
33

44
describe("hanzi2num", () => {
55
describe("num2hanzi(0.53212121222)", () => {
@@ -33,9 +33,9 @@ describe("hanzi2num", () => {
3333
});
3434
});
3535

36-
describe("num2hanzi(-(10**10+99))", () => {
36+
describe("num2hanzi(-(1e+10 + 99))", () => {
3737
it("should translate small negative float numner to hanzi", () => {
38-
assert.equal(num2hanzi(-(10 ** 10 + 99)), "負一百億零九十九");
38+
assert.equal(num2hanzi(-(1e+10 + 99)), "負一百億零九十九");
3939
});
4040
});
4141

@@ -63,17 +63,41 @@ describe("hanzi2num", () => {
6363
});
6464
});
6565

66-
describe('hanzi2num("二十一京二千三百四十五兆六千七百八十億零九百萬零二百五十有一")', () => {
66+
describe('hanzi2numstr("二十一京二千三百四十五兆六千七百八十億零九百萬零二百五十有一")', () => {
6767
it("should translate hanzi to number correctly", () => {
6868
assert.equal(
69-
hanzi2num(
69+
hanzi2numstr(
7070
"二十一京二千三百四十五兆六千七百八十億零九百萬零二百五十有一"
7171
),
72-
212345678009000260
72+
"212345678009000251"
7373
);
7474
});
7575
});
7676

77+
describe('hanzi2numstr("一極零二")', () => {
78+
it("should translate hanzi to number correctly", () => {
79+
assert.equal(
80+
hanzi2numstr("一極零二"),
81+
"1000000000000000000000000000000000000000000000002");
82+
});
83+
});
84+
85+
describe('hanzi2numstr("一極零二又三漠")', () => {
86+
it("should translate hanzi to number correctly", () => {
87+
assert.equal(
88+
hanzi2numstr("一極零二又三漠"),
89+
"1000000000000000000000000000000000000000000000002.000000000003");
90+
});
91+
});
92+
93+
describe('hanzi2numstr("一極零二京")', () => {
94+
it("should translate hanzi to number correctly", () => {
95+
assert.equal(
96+
hanzi2numstr("一極零二京"),
97+
"1.00000000000000000000000000000002e+48");
98+
});
99+
});
100+
77101
describe('hanzi2num("極")', () => {
78102
it("should translate hanzi to number correctly", () => {
79103
assert.equal(hanzi2num("極"), 1e+48);

0 commit comments

Comments
 (0)