Skip to content

Commit a8ec067

Browse files
committed
added test cases for 渺、埃、尘、沙、纤、微, failed for 纤 and 尘 - need code change for compiler
1 parent 5deb5d3 commit a8ec067

File tree

1 file changed

+61
-11
lines changed

1 file changed

+61
-11
lines changed

test/hanzi2num.test.js

Lines changed: 61 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ var { num2hanzi, hanzi2num, hanzi2numstr } = require("../src/hanzi2num");
44
describe("hanzi2num", () => {
55
describe("num2hanzi(0.53212121222)", () => {
66
it("should translate float number to hanzi correctly", () => {
7-
assert.strictEqual(num2hanzi(0.53212121222), "五分三釐二毫一絲二忽一微二纖一沙二塵二埃二渺");
7+
assert.strictEqual(
8+
num2hanzi(0.53212121222),
9+
"五分三釐二毫一絲二忽一微二纖一沙二塵二埃二渺"
10+
);
811
});
912
});
1013

@@ -35,7 +38,7 @@ describe("hanzi2num", () => {
3538

3639
describe("num2hanzi(-(1e+10 + 99))", () => {
3740
it("should translate small negative float numner to hanzi", () => {
38-
assert.strictEqual(num2hanzi(-(1e+10 + 99)), "負一百億零九十九");
41+
assert.strictEqual(num2hanzi(-(1e10 + 99)), "負一百億零九十九");
3942
});
4043
});
4144

@@ -53,7 +56,10 @@ describe("hanzi2num", () => {
5356

5457
describe('hanzi2num("負一又二分三釐四毫五絲六忽七微")', () => {
5558
it("should translate hanzi to number correctly", () => {
56-
assert.strictEqual(hanzi2num("負一又二分三釐四毫五絲六忽七微"), -1.234567);
59+
assert.strictEqual(
60+
hanzi2num("負一又二分三釐四毫五絲六忽七微"),
61+
-1.234567
62+
);
5763
});
5864
});
5965

@@ -78,29 +84,32 @@ describe("hanzi2num", () => {
7884
it("should translate hanzi to number correctly", () => {
7985
assert.strictEqual(
8086
hanzi2numstr("一極零二"),
81-
"1000000000000000000000000000000000000000000000002");
87+
"1000000000000000000000000000000000000000000000002"
88+
);
8289
});
8390
});
8491

8592
describe('hanzi2numstr("一極零二又三漠")', () => {
8693
it("should translate hanzi to number correctly", () => {
8794
assert.strictEqual(
8895
hanzi2numstr("一極零二又三漠"),
89-
"1000000000000000000000000000000000000000000000002.000000000003");
96+
"1000000000000000000000000000000000000000000000002.000000000003"
97+
);
9098
});
9199
});
92100

93101
describe('hanzi2numstr("一極零二京")', () => {
94102
it("should translate hanzi to number correctly", () => {
95103
assert.strictEqual(
96104
hanzi2numstr("一極零二京"),
97-
"1.00000000000000000000000000000002e+48");
105+
"1.00000000000000000000000000000002e+48"
106+
);
98107
});
99108
});
100109

101110
describe('hanzi2num("極")', () => {
102111
it("should translate hanzi to number correctly", () => {
103-
assert.strictEqual(hanzi2num("極"), 1e+48);
112+
assert.strictEqual(hanzi2num("極"), 1e48);
104113
});
105114
});
106115

@@ -119,6 +128,44 @@ describe("hanzi2num", () => {
119128
});
120129
});
121130

131+
//渺、埃、尘、沙、纤、微
132+
describe('hanzi2num("一微")', () => {
133+
it("should translate hanzi to number correctly", () => {
134+
assert.strictEqual(hanzi2num("一微"), 1e-6);
135+
});
136+
});
137+
138+
describe('hanzi2num("一纤")', () => {
139+
it("should translate hanzi to number correctly", () => {
140+
assert.strictEqual(hanzi2num("一纤"), 1e-7);
141+
});
142+
});
143+
144+
describe('hanzi2num("一沙")', () => {
145+
it("should translate hanzi to number correctly", () => {
146+
assert.strictEqual(hanzi2num("一沙"), 1e-8);
147+
});
148+
});
149+
150+
describe('hanzi2num("一尘")', () => {
151+
it("should translate hanzi to number correctly", () => {
152+
assert.strictEqual(hanzi2num("一尘"), 1e-9);
153+
});
154+
});
155+
156+
describe('hanzi2num("一埃")', () => {
157+
it("should translate hanzi to number correctly", () => {
158+
assert.strictEqual(hanzi2num("一埃"), 1e-10);
159+
});
160+
});
161+
162+
describe('hanzi2num("一渺")', () => {
163+
it("should translate hanzi to number correctly", () => {
164+
assert.strictEqual(hanzi2num("一渺"), 1e-11);
165+
});
166+
});
167+
// ended 渺、埃、尘、沙、纤、微
168+
122169
describe('hanzi2num("一漠")', () => {
123170
it("should translate hanzi to number correctly", () => {
124171
assert.strictEqual(hanzi2num("一漠"), 1e-12);
@@ -187,7 +234,7 @@ describe("hanzi2num", () => {
187234

188235
describe('hanzi2num("十萬")', () => {
189236
it("should translate hanzi to number correctly", () => {
190-
assert.strictEqual(hanzi2num("十萬"), 1e+5);
237+
assert.strictEqual(hanzi2num("十萬"), 1e5);
191238
});
192239
});
193240

@@ -199,7 +246,7 @@ describe("hanzi2num", () => {
199246

200247
describe('hanzi2num("萬億")', () => {
201248
it("should translate hanzi to number correctly", () => {
202-
assert.strictEqual(hanzi2num("萬億"), 1e+12);
249+
assert.strictEqual(hanzi2num("萬億"), 1e12);
203250
});
204251
});
205252

@@ -211,13 +258,16 @@ describe("hanzi2num", () => {
211258

212259
describe('hanzi2num("三·一四一五九二六五三五八九七九三")', () => {
213260
it("should translate hanzi to number correctly", () => {
214-
assert.strictEqual(hanzi2num("三·一四一五九二六五三五八九七九三"), Math.PI);
261+
assert.strictEqual(
262+
hanzi2num("三·一四一五九二六五三五八九七九三"),
263+
Math.PI
264+
);
215265
});
216266
});
217267

218268
describe('hanzi2num("一二京三四五六兆七〇〇〇億")', () => {
219269
it("should translate hanzi to number correctly", () => {
220-
assert.strictEqual(hanzi2num("一二京三四五六兆七〇〇〇億"), 1.234567e+17);
270+
assert.strictEqual(hanzi2num("一二京三四五六兆七〇〇〇億"), 1.234567e17);
221271
});
222272
});
223273

0 commit comments

Comments
 (0)