|
1 | 1 | var assert = require("assert");
|
2 |
| -var { num2hanzi, hanzi2num } = require("../src/hanzi2num"); |
| 2 | +var { num2hanzi, hanzi2num, hanzi2numstr } = require("../src/hanzi2num"); |
3 | 3 |
|
4 | 4 | describe("hanzi2num", () => {
|
5 | 5 | describe("num2hanzi(0.53212121222)", () => {
|
@@ -33,9 +33,9 @@ describe("hanzi2num", () => {
|
33 | 33 | });
|
34 | 34 | });
|
35 | 35 |
|
36 |
| - describe("num2hanzi(-(10**10+99))", () => { |
| 36 | + describe("num2hanzi(-(1e+10 + 99))", () => { |
37 | 37 | it("should translate small negative float numner to hanzi", () => {
|
38 |
| - assert.equal(num2hanzi(-(10 ** 10 + 99)), "負一百億零九十九"); |
| 38 | + assert.equal(num2hanzi(-(1e+10 + 99)), "負一百億零九十九"); |
39 | 39 | });
|
40 | 40 | });
|
41 | 41 |
|
@@ -63,17 +63,41 @@ describe("hanzi2num", () => {
|
63 | 63 | });
|
64 | 64 | });
|
65 | 65 |
|
66 |
| - describe('hanzi2num("二十一京二千三百四十五兆六千七百八十億零九百萬零二百五十有一")', () => { |
| 66 | + describe('hanzi2numstr("二十一京二千三百四十五兆六千七百八十億零九百萬零二百五十有一")', () => { |
67 | 67 | it("should translate hanzi to number correctly", () => {
|
68 | 68 | assert.equal(
|
69 |
| - hanzi2num( |
| 69 | + hanzi2numstr( |
70 | 70 | "二十一京二千三百四十五兆六千七百八十億零九百萬零二百五十有一"
|
71 | 71 | ),
|
72 |
| - 212345678009000260 |
| 72 | + "212345678009000251" |
73 | 73 | );
|
74 | 74 | });
|
75 | 75 | });
|
76 | 76 |
|
| 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 | + |
77 | 101 | describe('hanzi2num("極")', () => {
|
78 | 102 | it("should translate hanzi to number correctly", () => {
|
79 | 103 | assert.equal(hanzi2num("極"), 1e+48);
|
|
0 commit comments