Subversion Repository Public Repository

litesoft

Diff Revisions 150 vs 151 for /trunk/Java/core/Server/tests/org/litesoft/core/formatters/NumericFormatterTest.java

Diff revisions: vs.
  @@ -20,194 +20,221 @@
20 20 junit.textui.TestRunner.run( suite() );
21 21 }
22 22
23 - public void testCreateFormatter() throws Exception
23 + public void testCreateFormatter()
24 + throws Exception
24 25 {
25 - NumericFormatter nf = new NumericFormatter( );
26 + NumericFormatter nf = new NumericFormatter();
26 27 NFparsedparts zNFparsedparts = nf.parseInto( "a123" );
27 28 assertNotNull( zNFparsedparts );
28 29 }
29 30
30 31 //***************** Parts Tests ******************************
31 - public void testParseIntoBeforeDigitsPart1() throws Exception
32 + public void testParseIntoBeforeDigitsPart1()
33 + throws Exception
32 34 {
33 - NumericFormatter nf = new NumericFormatter( );
35 + NumericFormatter nf = new NumericFormatter();
34 36 NFparsedparts zNFparsedparts = nf.parseInto( "a123" );
35 37 assertEquals( "", "a", zNFparsedparts.getBeforeAnyDigits() );
36 38 }
37 39
38 - public void testParseIntoBeforeDigitsPart2() throws Exception
40 + public void testParseIntoBeforeDigitsPart2()
41 + throws Exception
39 42 {
40 - NumericFormatter nf = new NumericFormatter( );
43 + NumericFormatter nf = new NumericFormatter();
41 44 NFparsedparts zNFparsedparts = nf.parseInto( "$ 123" );
42 45 assertEquals( "", "$ ", zNFparsedparts.getBeforeAnyDigits() );
43 46 }
44 47
45 - public void testParseIntoWholeDigitsPart() throws Exception
48 + public void testParseIntoWholeDigitsPart()
49 + throws Exception
46 50 {
47 - NumericFormatter nf = new NumericFormatter( );
51 + NumericFormatter nf = new NumericFormatter();
48 52 NFparsedparts zNFparsedparts = nf.parseInto( "123.54" );
49 53 assertEquals( "", "123", zNFparsedparts.getWholeDigits() );
50 54 }
51 55
52 - public void testParseIntoIsDecimalFound() throws Exception
56 + public void testParseIntoIsDecimalFound()
57 + throws Exception
53 58 {
54 - NumericFormatter nf = new NumericFormatter( );
59 + NumericFormatter nf = new NumericFormatter();
55 60 NFparsedparts zNFparsedparts = nf.parseInto( "123.54" );
56 61 assertTrue( "", zNFparsedparts.isDecimalFound() );
57 62 }
58 63
59 - public void testParseIntoFractionalDigits() throws Exception
64 + public void testParseIntoFractionalDigits()
65 + throws Exception
60 66 {
61 - NumericFormatter nf = new NumericFormatter( );
67 + NumericFormatter nf = new NumericFormatter();
62 68 NFparsedparts zNFparsedparts = nf.parseInto( "123.54" );
63 69 assertEquals( "", "54", zNFparsedparts.getFractionalDigits() );
64 70 }
65 71
66 - public void testParseIntoAfterDigitsPart1() throws Exception
72 + public void testParseIntoAfterDigitsPart1()
73 + throws Exception
67 74 {
68 - NumericFormatter nf = new NumericFormatter( );
75 + NumericFormatter nf = new NumericFormatter();
69 76 NFparsedparts zNFparsedparts = nf.parseInto( "123.54" );
70 77 assertEquals( "", "", zNFparsedparts.getAfterAnyDigits() );
71 78 }
72 79
73 - public void testParseIntoAfterDigitsPart2() throws Exception
80 + public void testParseIntoAfterDigitsPart2()
81 + throws Exception
74 82 {
75 - NumericFormatter nf = new NumericFormatter( );
83 + NumericFormatter nf = new NumericFormatter();
76 84 NFparsedparts zNFparsedparts = nf.parseInto( "123.54z" );
77 85 assertEquals( "", "z", zNFparsedparts.getAfterAnyDigits() );
78 86 }
79 87 //**********************************************************
80 88
81 - public void testParseIntoNegativeInt() throws Exception
89 + public void testParseIntoNegativeInt()
90 + throws Exception
82 91 {
83 - NumericFormatter nf = new NumericFormatter( );
92 + NumericFormatter nf = new NumericFormatter();
84 93 NFparsedparts zNFparsedparts = nf.parseInto( "-123" );
85 94
86 - assertEquals( "", "-123", zNFparsedparts.toString());
95 + assertEquals( "", "-123", zNFparsedparts.toString() );
87 96 }
88 97
89 - public void testParseIntoDotButNoDecimal() throws Exception
98 + public void testParseIntoDotButNoDecimal()
99 + throws Exception
90 100 {
91 - NumericFormatter nf = new NumericFormatter( );
101 + NumericFormatter nf = new NumericFormatter();
92 102 NFparsedparts zNFparsedparts = nf.parseInto( "123." );
93 103
94 - assertEquals( "", "123", zNFparsedparts.toString());
104 + assertEquals( "", "123", zNFparsedparts.toString() );
95 105 }
96 106
97 - public void testParseIntoNegativeDecimal() throws Exception
107 + public void testParseIntoNegativeDecimal()
108 + throws Exception
98 109 {
99 - NumericFormatter nf = new NumericFormatter( );
110 + NumericFormatter nf = new NumericFormatter();
100 111 NFparsedparts zNFparsedparts = nf.parseInto( "-123.24" );
101 112
102 - assertEquals( "", "-123.24", zNFparsedparts.toString());
113 + assertEquals( "", "-123.24", zNFparsedparts.toString() );
103 114 }
104 115
105 - public void testParseIntoPositiveDecimal() throws Exception
116 + public void testParseIntoPositiveDecimal()
117 + throws Exception
106 118 {
107 - NumericFormatter nf = new NumericFormatter( );
119 + NumericFormatter nf = new NumericFormatter();
108 120 NFparsedparts zNFparsedparts = nf.parseInto( "123.24" );
109 121
110 - assertEquals( "", "123.24", zNFparsedparts.toString());
122 + assertEquals( "", "123.24", zNFparsedparts.toString() );
111 123 }
112 124
113 - public void testParseIntoPartialFractional() throws Exception
125 + public void testParseIntoPartialFractional()
126 + throws Exception
114 127 {
115 - NumericFormatter nf = new NumericFormatter( );
128 + NumericFormatter nf = new NumericFormatter();
116 129 NFparsedparts zNFparsedparts = nf.parseInto( "3.5" );
117 130
118 - assertEquals( "", "3.5", zNFparsedparts.toString());
131 + assertEquals( "", "3.5", zNFparsedparts.toString() );
119 132 }
120 133
121 - public void testParseIntoNull() throws Exception
134 + public void testParseIntoNull()
135 + throws Exception
122 136 {
123 - NumericFormatter nf = new NumericFormatter( );
137 + NumericFormatter nf = new NumericFormatter();
124 138 NFparsedparts zNFparsedparts = nf.parseInto( null );
125 139
126 - assertEquals( "", "0", zNFparsedparts.toString());
140 + assertEquals( "", "0", zNFparsedparts.toString() );
127 141 }
128 142
129 - public void testParseIntoZeroLengthString() throws Exception
143 + public void testParseIntoZeroLengthString()
144 + throws Exception
130 145 {
131 - NumericFormatter nf = new NumericFormatter( );
146 + NumericFormatter nf = new NumericFormatter();
132 147 NFparsedparts zNFparsedparts = nf.parseInto( "" );
133 148
134 - assertEquals( "", "0", zNFparsedparts.toString());
149 + assertEquals( "", "0", zNFparsedparts.toString() );
135 150 }
136 151
137 - public void testParseIntoZero1() throws Exception
152 + public void testParseIntoZero1()
153 + throws Exception
138 154 {
139 - NumericFormatter nf = new NumericFormatter( );
155 + NumericFormatter nf = new NumericFormatter();
140 156 NFparsedparts zNFparsedparts = nf.parseInto( "-.0" );
141 157
142 - assertEquals( "", "0.0", zNFparsedparts.toString());
158 + assertEquals( "", "0.0", zNFparsedparts.toString() );
143 159 }
144 160
145 - public void testParseIntoZero2() throws Exception
161 + public void testParseIntoZero2()
162 + throws Exception
146 163 {
147 - NumericFormatter nf = new NumericFormatter( );
164 + NumericFormatter nf = new NumericFormatter();
148 165 NFparsedparts zNFparsedparts = nf.parseInto( "-0" );
149 166
150 - assertEquals( "", "0", zNFparsedparts.toString());
167 + assertEquals( "", "0", zNFparsedparts.toString() );
151 168 }
152 169
153 - public void testParseIntoFractionalOnly() throws Exception
170 + public void testParseIntoFractionalOnly()
171 + throws Exception
154 172 {
155 - NumericFormatter nf = new NumericFormatter( );
173 + NumericFormatter nf = new NumericFormatter();
156 174 NFparsedparts zNFparsedparts = nf.parseInto( ".58" );
157 175
158 - assertEquals( "", "0.58", zNFparsedparts.toString());
176 + assertEquals( "", "0.58", zNFparsedparts.toString() );
159 177 }
160 178
161 - public void testParseIntoNegativeFractionalOnly() throws Exception
179 + public void testParseIntoNegativeFractionalOnly()
180 + throws Exception
162 181 {
163 - NumericFormatter nf = new NumericFormatter( );
182 + NumericFormatter nf = new NumericFormatter();
164 183 NFparsedparts zNFparsedparts = nf.parseInto( "-.58" );
165 184
166 - assertEquals( "", "-0.58", zNFparsedparts.toString());
185 + assertEquals( "", "-0.58", zNFparsedparts.toString() );
167 186 }
168 187
169 - public void testParseIntoFractionalOnlyPlusNonDigit() throws Exception
188 + public void testParseIntoFractionalOnlyPlusNonDigit()
189 + throws Exception
170 190 {
171 - NumericFormatter nf = new NumericFormatter( );
191 + NumericFormatter nf = new NumericFormatter();
172 192 NFparsedparts zNFparsedparts = nf.parseInto( ".58c" );
173 193
174 - assertEquals( "", "0.58c", zNFparsedparts.toString());
194 + assertEquals( "", "0.58c", zNFparsedparts.toString() );
175 195 }
176 196
177 - public void testParseIntoDollars() throws Exception
197 + public void testParseIntoDollars()
198 + throws Exception
178 199 {
179 - NumericFormatter nf = new NumericFormatter( );
200 + NumericFormatter nf = new NumericFormatter();
180 201 NFparsedparts zNFparsedparts = nf.parseInto( "$3.58" );
181 202
182 - assertEquals( "", "$3.58", zNFparsedparts.toString());
203 + assertEquals( "", "$3.58", zNFparsedparts.toString() );
183 204 }
184 205
185 - public void testParseIntoWithCommas() throws Exception
206 + public void testParseIntoWithCommas()
207 + throws Exception
186 208 {
187 - NumericFormatter nf = new NumericFormatter( );
209 + NumericFormatter nf = new NumericFormatter();
188 210 NFparsedparts zNFparsedparts = nf.parseInto( "$1,007.58" );
189 211
190 - assertEquals( "", "$1,007.58", zNFparsedparts.toString());
212 + assertEquals( "", "$1,007.58", zNFparsedparts.toString() );
191 213 }
192 214
193 - public void testParseIntoWithExtraCommas() throws Exception
215 + public void testParseIntoWithExtraCommas()
216 + throws Exception
194 217 {
195 - NumericFormatter nf = new NumericFormatter( );
218 + NumericFormatter nf = new NumericFormatter();
196 219 NFparsedparts zNFparsedparts = nf.parseInto( "$1,00,7.58" );
197 220
198 - assertEquals( "", "$1,00,7.58", zNFparsedparts.toString());
221 + assertEquals( "", "$1,00,7.58", zNFparsedparts.toString() );
199 222 }
200 223
201 - public void testParseIntoWithExtraFractionPart() throws Exception
224 + public void testParseIntoWithExtraFractionPart()
225 + throws Exception
202 226 {
203 - NumericFormatter nf = new NumericFormatter( );
227 + NumericFormatter nf = new NumericFormatter();
204 228 NFparsedparts zNFparsedparts = nf.parseInto( "1007.584" );
205 229
206 - assertEquals( "", "1007.584", zNFparsedparts.toString());
230 + assertEquals( "", "1007.584", zNFparsedparts.toString() );
207 231 }
208 232
209 - /***************** NumericFormatter & FormatterFactory test **************/
210 - public void testFormatterFactory0() throws Exception
233 + /**
234 + * ************** NumericFormatter & FormatterFactory test *************
235 + */
236 + public void testFormatterFactory0()
237 + throws Exception
211 238 {
212 239 String zFormat = "0";
213 240
  @@ -220,7 +247,8 @@
220 247 assertEquals( "", "0", zFormatted );
221 248 }
222 249
223 - public void testFormatterFactory1() throws Exception
250 + public void testFormatterFactory1()
251 + throws Exception
224 252 {
225 253 String zFormat = "0";
226 254
  @@ -233,7 +261,8 @@
233 261 assertEquals( "", "7", zFormatted );
234 262 }
235 263
236 - public void testFormatterFactory2() throws Exception
264 + public void testFormatterFactory2()
265 + throws Exception
237 266 {
238 267 String zFormat = "0";
239 268
  @@ -246,7 +275,8 @@
246 275 assertEquals( "", "-7", zFormatted );
247 276 }
248 277
249 - public void testFormatterFactory3() throws Exception
278 + public void testFormatterFactory3()
279 + throws Exception
250 280 {
251 281 String zFormat = "#";
252 282
  @@ -259,7 +289,8 @@
259 289 assertEquals( "", "-75", zFormatted );
260 290 }
261 291
262 - public void testFormatterFactory4() throws Exception
292 + public void testFormatterFactory4()
293 + throws Exception
263 294 {
264 295 String zFormat = "#0";
265 296
  @@ -272,7 +303,8 @@
272 303 assertEquals( "", "7", zFormatted );
273 304 }
274 305
275 - public void testFormatterFactory5() throws Exception
306 + public void testFormatterFactory5()
307 + throws Exception
276 308 {
277 309 String zFormat = "#0";
278 310
  @@ -285,7 +317,8 @@
285 317 assertEquals( "", "75", zFormatted );
286 318 }
287 319
288 - public void testFormatterFactory6() throws Exception
320 + public void testFormatterFactory6()
321 + throws Exception
289 322 {
290 323 String zFormat = "#0";
291 324
  @@ -298,7 +331,8 @@
298 331 assertEquals( "", "0", zFormatted );
299 332 }
300 333
301 - public void testFormatterFactory7() throws Exception
334 + public void testFormatterFactory7()
335 + throws Exception
302 336 {
303 337 String zFormat = "#,##0";
304 338
  @@ -311,7 +345,8 @@
311 345 assertEquals( "", "1,984", zFormatted );
312 346 }
313 347
314 - public void testFormatterFactory8() throws Exception
348 + public void testFormatterFactory8()
349 + throws Exception
315 350 {
316 351 String zFormat = "#,##0";
317 352
  @@ -324,7 +359,8 @@
324 359 assertEquals( "", "198,456", zFormatted );
325 360 }
326 361
327 - public void testFormatterFactory9() throws Exception
362 + public void testFormatterFactory9()
363 + throws Exception
328 364 {
329 365 String zFormat = "#,##0";
330 366
  @@ -337,7 +373,8 @@
337 373 assertEquals( "", "2,345,678", zFormatted );
338 374 }
339 375
340 - public void testFormatterFactory10() throws Exception
376 + public void testFormatterFactory10()
377 + throws Exception
341 378 {
342 379 String zFormat = "#,##0";
343 380
  @@ -350,7 +387,8 @@
350 387 assertEquals( "", "999,923,456,789,654,473", zFormatted );
351 388 }
352 389
353 - public void testFormatterFactory11() throws Exception
390 + public void testFormatterFactory11()
391 + throws Exception
354 392 {
355 393 String zFormat = "#,##0";
356 394
  @@ -363,8 +401,11 @@
363 401 assertEquals( "", "234", zFormatted );
364 402 }
365 403
366 - /***************** Fractional Tests *****************/
367 - public void testFormatterFactoryFractionalTests0() throws Exception
404 + /**
405 + * ************** Fractional Tests ****************
406 + */
407 + public void testFormatterFactoryFractionalTests0()
408 + throws Exception
368 409 {
369 410 String zFormat = "0.0";
370 411
  @@ -377,7 +418,8 @@
377 418 assertEquals( "", "4.0", zFormatted );
378 419 }
379 420
380 - public void testFormatterFactoryFractionalTests1() throws Exception
421 + public void testFormatterFactoryFractionalTests1()
422 + throws Exception
381 423 {
382 424 String zFormat = "0.0";
383 425
  @@ -390,7 +432,8 @@
390 432 assertEquals( "", "4.5", zFormatted );
391 433 }
392 434
393 - public void testFormatterFactoryFractionalTests2() throws Exception
435 + public void testFormatterFactoryFractionalTests2()
436 + throws Exception
394 437 {
395 438 String zFormat = "0.00";
396 439
  @@ -403,7 +446,8 @@
403 446 assertEquals( "", "4.50", zFormatted );
404 447 }
405 448
406 - public void testFormatterFactoryFractionalTests3() throws Exception
449 + public void testFormatterFactoryFractionalTests3()
450 + throws Exception
407 451 {
408 452 String zFormat = "0.0#";
409 453
  @@ -416,7 +460,8 @@
416 460 assertEquals( "", "4.56", zFormatted );
417 461 }
418 462
419 - public void testFormatterFactoryFractionalTests4() throws Exception
463 + public void testFormatterFactoryFractionalTests4()
464 + throws Exception
420 465 {
421 466 String zFormat = "0.0#";
422 467
  @@ -429,7 +474,8 @@
429 474 assertEquals( "", "4.0", zFormatted );
430 475 }
431 476
432 - public void testFormatterFactoryFractionalTests5() throws Exception
477 + public void testFormatterFactoryFractionalTests5()
478 + throws Exception
433 479 {
434 480 String zFormat = "0.0#";
435 481
  @@ -442,8 +488,11 @@
442 488 assertEquals( "", "4.567", zFormatted );
443 489 }
444 490
445 - /******************* Complete Number ***********************/
446 - public void testFormatterFactoryCompleteTests0() throws Exception
491 + /**
492 + * **************** Complete Number **********************
493 + */
494 + public void testFormatterFactoryCompleteTests0()
495 + throws Exception
447 496 {
448 497 String zFormat = "#0.0#";
449 498
  @@ -456,7 +505,8 @@
456 505 assertEquals( "", "44.567", zFormatted );
457 506 }
458 507
459 - public void testFormatterFactoryCompleteTests1() throws Exception
508 + public void testFormatterFactoryCompleteTests1()
509 + throws Exception
460 510 {
461 511 String zFormat = "#0.00";
462 512
  @@ -469,7 +519,8 @@
469 519 assertEquals( "", "44.44", zFormatted );
470 520 }
471 521
472 - public void testFormatterFactoryCompleteTests2() throws Exception
522 + public void testFormatterFactoryCompleteTests2()
523 + throws Exception
473 524 {
474 525 String zFormat = "#0.00";
475 526
  @@ -482,7 +533,8 @@
482 533 assertEquals( "", "44.44", zFormatted );
483 534 }
484 535
485 - public void testFormatterFactoryCompleteTests3() throws Exception
536 + public void testFormatterFactoryCompleteTests3()
537 + throws Exception
486 538 {
487 539 String zFormat = "#0.00";
488 540
  @@ -495,7 +547,8 @@
495 547 assertEquals( "", "44.45", zFormatted );
496 548 }
497 549
498 - public void testFormatterFactoryCompleteTests4() throws Exception
550 + public void testFormatterFactoryCompleteTests4()
551 + throws Exception
499 552 {
500 553 String zFormat = "#,##0.00";
501 554