@@ -4,7 +4,10 @@ var { num2hanzi, hanzi2num, hanzi2numstr } = require("../src/hanzi2num");
4
4
describe ( "hanzi2num" , ( ) => {
5
5
describe ( "num2hanzi(0.53212121222)" , ( ) => {
6
6
it ( "should translate float number to hanzi correctly" , ( ) => {
7
- assert . strictEqual ( num2hanzi ( 0.53212121222 ) , "五分三釐二毫一絲二忽一微二纖一沙二塵二埃二渺" ) ;
7
+ assert . strictEqual (
8
+ num2hanzi ( 0.53212121222 ) ,
9
+ "五分三釐二毫一絲二忽一微二纖一沙二塵二埃二渺"
10
+ ) ;
8
11
} ) ;
9
12
} ) ;
10
13
@@ -35,7 +38,7 @@ describe("hanzi2num", () => {
35
38
36
39
describe ( "num2hanzi(-(1e+10 + 99))" , ( ) => {
37
40
it ( "should translate small negative float numner to hanzi" , ( ) => {
38
- assert . strictEqual ( num2hanzi ( - ( 1e+10 + 99 ) ) , "負一百億零九十九" ) ;
41
+ assert . strictEqual ( num2hanzi ( - ( 1e10 + 99 ) ) , "負一百億零九十九" ) ;
39
42
} ) ;
40
43
} ) ;
41
44
@@ -53,7 +56,10 @@ describe("hanzi2num", () => {
53
56
54
57
describe ( 'hanzi2num("負一又二分三釐四毫五絲六忽七微")' , ( ) => {
55
58
it ( "should translate hanzi to number correctly" , ( ) => {
56
- assert . strictEqual ( hanzi2num ( "負一又二分三釐四毫五絲六忽七微" ) , - 1.234567 ) ;
59
+ assert . strictEqual (
60
+ hanzi2num ( "負一又二分三釐四毫五絲六忽七微" ) ,
61
+ - 1.234567
62
+ ) ;
57
63
} ) ;
58
64
} ) ;
59
65
@@ -78,29 +84,32 @@ describe("hanzi2num", () => {
78
84
it ( "should translate hanzi to number correctly" , ( ) => {
79
85
assert . strictEqual (
80
86
hanzi2numstr ( "一極零二" ) ,
81
- "1000000000000000000000000000000000000000000000002" ) ;
87
+ "1000000000000000000000000000000000000000000000002"
88
+ ) ;
82
89
} ) ;
83
90
} ) ;
84
91
85
92
describe ( 'hanzi2numstr("一極零二又三漠")' , ( ) => {
86
93
it ( "should translate hanzi to number correctly" , ( ) => {
87
94
assert . strictEqual (
88
95
hanzi2numstr ( "一極零二又三漠" ) ,
89
- "1000000000000000000000000000000000000000000000002.000000000003" ) ;
96
+ "1000000000000000000000000000000000000000000000002.000000000003"
97
+ ) ;
90
98
} ) ;
91
99
} ) ;
92
100
93
101
describe ( 'hanzi2numstr("一極零二京")' , ( ) => {
94
102
it ( "should translate hanzi to number correctly" , ( ) => {
95
103
assert . strictEqual (
96
104
hanzi2numstr ( "一極零二京" ) ,
97
- "1.00000000000000000000000000000002e+48" ) ;
105
+ "1.00000000000000000000000000000002e+48"
106
+ ) ;
98
107
} ) ;
99
108
} ) ;
100
109
101
110
describe ( 'hanzi2num("極")' , ( ) => {
102
111
it ( "should translate hanzi to number correctly" , ( ) => {
103
- assert . strictEqual ( hanzi2num ( "極" ) , 1e+48 ) ;
112
+ assert . strictEqual ( hanzi2num ( "極" ) , 1e48 ) ;
104
113
} ) ;
105
114
} ) ;
106
115
@@ -119,6 +128,44 @@ describe("hanzi2num", () => {
119
128
} ) ;
120
129
} ) ;
121
130
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
+
122
169
describe ( 'hanzi2num("一漠")' , ( ) => {
123
170
it ( "should translate hanzi to number correctly" , ( ) => {
124
171
assert . strictEqual ( hanzi2num ( "一漠" ) , 1e-12 ) ;
@@ -187,7 +234,7 @@ describe("hanzi2num", () => {
187
234
188
235
describe ( 'hanzi2num("十萬")' , ( ) => {
189
236
it ( "should translate hanzi to number correctly" , ( ) => {
190
- assert . strictEqual ( hanzi2num ( "十萬" ) , 1e+5 ) ;
237
+ assert . strictEqual ( hanzi2num ( "十萬" ) , 1e5 ) ;
191
238
} ) ;
192
239
} ) ;
193
240
@@ -199,7 +246,7 @@ describe("hanzi2num", () => {
199
246
200
247
describe ( 'hanzi2num("萬億")' , ( ) => {
201
248
it ( "should translate hanzi to number correctly" , ( ) => {
202
- assert . strictEqual ( hanzi2num ( "萬億" ) , 1e+12 ) ;
249
+ assert . strictEqual ( hanzi2num ( "萬億" ) , 1e12 ) ;
203
250
} ) ;
204
251
} ) ;
205
252
@@ -211,13 +258,16 @@ describe("hanzi2num", () => {
211
258
212
259
describe ( 'hanzi2num("三·一四一五九二六五三五八九七九三")' , ( ) => {
213
260
it ( "should translate hanzi to number correctly" , ( ) => {
214
- assert . strictEqual ( hanzi2num ( "三·一四一五九二六五三五八九七九三" ) , Math . PI ) ;
261
+ assert . strictEqual (
262
+ hanzi2num ( "三·一四一五九二六五三五八九七九三" ) ,
263
+ Math . PI
264
+ ) ;
215
265
} ) ;
216
266
} ) ;
217
267
218
268
describe ( 'hanzi2num("一二京三四五六兆七〇〇〇億")' , ( ) => {
219
269
it ( "should translate hanzi to number correctly" , ( ) => {
220
- assert . strictEqual ( hanzi2num ( "一二京三四五六兆七〇〇〇億" ) , 1.234567e+17 ) ;
270
+ assert . strictEqual ( hanzi2num ( "一二京三四五六兆七〇〇〇億" ) , 1.234567e17 ) ;
221
271
} ) ;
222
272
} ) ;
223
273
0 commit comments