Revision 38291

View differences:

tags/v2_0_0_Build_2047/libraries/libIverUtiles/src-test/org/gvsig/utils/stringNumberUtilities/TestStringNumberUtilities.java
1
package org.gvsig.utils.stringNumberUtilities;
2

  
3
import org.gvsig.utils.stringNumberUtilities.StringNumberUtilities;
4

  
5
import junit.framework.TestCase;
6

  
7
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8
 *
9
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
24
 *
25
 * For more information, contact:
26
 *
27
 *  Generalitat Valenciana
28
 *   Conselleria d'Infraestructures i Transport
29
 *   Av. Blasco Ib??ez, 50
30
 *   46010 VALENCIA
31
 *   SPAIN
32
 *
33
 *      +34 963862235
34
 *   gvsig@gva.es
35
 *      www.gvsig.gva.es
36
 *
37
 *    or
38
 *
39
 *   IVER T.I. S.A
40
 *   Salamanca 50
41
 *   46005 Valencia
42
 *   Spain
43
 *
44
 *   +34 963163400
45
 *   dac@iver.es
46
 */
47

  
48
/**
49
 * Tests the methods of the class StringNumberUtilities
50
 * 
51
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
52
 */
53
public class TestStringNumberUtilities extends TestCase{
54
	private String word;
55
	
56
	/*
57
	 *  (non-Javadoc)
58
	 * @see junit.framework.TestCase#setUp()
59
	 */
60
	protected void setUp() throws Exception {
61
		super.setUp();
62
		word = new String();
63
	}
64

  
65
	/*
66
	 *  (non-Javadoc)
67
	 * @see junit.framework.TestCase#tearDown()
68
	 */
69
	protected void tearDown() throws Exception {
70
		super.tearDown();
71
	}
72
	
73
	/**
74
	 * A test
75
	 */
76
	public void test1() {
77
		word = "2.3";
78
		ShowText.showIsNumberText(word);
79

  
80
		if (StringNumberUtilities.isNumber(word)) {
81
			ShowText.showYes();
82
		}
83
		else {
84
			ShowText.showNo();
85
			fail();
86
		}
87
	}
88

  
89
	/**
90
	 * A test
91
	 */
92
	public void test2() {
93
		word = "a as wz rwa";
94
		ShowText.showIsNumberText(word);
95

  
96
		if (StringNumberUtilities.isNumber(word)) {
97
			ShowText.showYes();
98
		}
99
		else {
100
			ShowText.showNo();
101
			fail();
102
		}
103
	}
104

  
105
	/**
106
	 * A test
107
	 */
108
	public void test3() {
109
		word = "2";
110
		ShowText.showIsNumberText(word);
111

  
112
		if (StringNumberUtilities.isNumber(word)) {
113
			ShowText.showYes();
114
		}
115
		else {
116
			ShowText.showNo();
117
			fail();
118
		}
119
	}
120

  
121
	/**
122
	 * A test
123
	 */
124
	public void test4() {
125
		word = "";
126
		ShowText.showIsNumberText(word);
127

  
128
		if (StringNumberUtilities.isNumber(word)) {
129
			ShowText.showYes();
130
		}
131
		else {
132
			ShowText.showNo();
133
			fail();
134
		}
135
	}
136

  
137
	/**
138
	 * A test
139
	 */
140
	public void test5() {
141
		word = "-2.3";
142
		ShowText.showIsNumberText(word);
143

  
144
		if (StringNumberUtilities.isNumber(word)) {
145
			ShowText.showYes();
146
		}
147
		else {
148
			ShowText.showNo();
149
			fail();
150
		}
151
	}
152

  
153
	/**
154
	 * A test
155
	 */
156
	public void test6() {
157
		word = "-300";
158
		ShowText.showIsNumberText(word);
159

  
160
		if (StringNumberUtilities.isNumber(word)) {
161
			ShowText.showYes();
162
		}
163
		else {
164
			ShowText.showNo();
165
			fail();
166
		}
167
	}
168

  
169
	/**
170
	 * A test
171
	 */
172
	public void test7() {
173
		word = "2.3";
174
		ShowText.showIsNaturalText(word);
175

  
176
		if (StringNumberUtilities.isNaturalNumber(word)) {
177
			ShowText.showYes();
178
		}
179
		else {
180
			ShowText.showNo();
181
			fail();
182
		}
183
	}
184

  
185
	/**
186
	 * A test
187
	 */
188
	public void test8() {
189
		word = "334";
190
		ShowText.showIsNaturalText(word);
191

  
192
		if (StringNumberUtilities.isNaturalNumber(word)) {
193
			ShowText.showYes();
194
		}
195
		else {
196
			ShowText.showNo();
197
			fail();
198
		}
199
	}
200

  
201
	/**
202
	 * A test
203
	 */
204
	public void test9() {
205
		word = "-2a3";
206
		ShowText.showIsIntegerText(word);
207

  
208
		if (StringNumberUtilities.isIntegerNumber(word)) {
209
			ShowText.showYes();
210
		}
211
		else {
212
			ShowText.showNo();
213
			fail();
214
		}
215
	}
216

  
217
	/**
218
	 * A test
219
	 */
220
	public void test10() {
221
		word = "-23";
222
		ShowText.showIsIntegerText(word);
223

  
224
		if (StringNumberUtilities.isIntegerNumber(word)) {
225
			ShowText.showYes();
226
		}
227
		else {
228
			ShowText.showNo();
229
			fail();
230
		}
231
	}
232
	
233
	/**
234
	 * A test
235
	 */
236
	public void test11() {
237
		word = "7";
238
		ShowText.showIsIntegerText(word);
239

  
240
		if (StringNumberUtilities.isIntegerNumber(word)) {
241
			ShowText.showYes();
242
		}
243
		else {
244
			ShowText.showNo();
245
			fail();
246
		}
247
	}
248
	
249
	/**
250
	 * A test
251
	 */
252
	public void test12() {
253
		word = "2.3";
254
		ShowText.showIsIntegerText(word);
255

  
256
		if (StringNumberUtilities.isIntegerNumber(word)) {
257
			ShowText.showYes();
258
		}
259
		else {
260
			ShowText.showNo();
261
			fail();
262
		}
263
	}
264

  
265
	/**
266
	 * A test
267
	 */
268
	public void test13() {
269
		word = "2.3";
270
		ShowText.showIsRealText(word);
271

  
272
		if (StringNumberUtilities.isRealNumber(word)) {
273
			ShowText.showYes();
274
		}
275
		else {
276
			ShowText.showNo();
277
			fail();
278
		}
279
	}
280
	
281
	/**
282
	 * A test
283
	 */
284
	public void test14() {
285
		word = "37";
286
		ShowText.showIsRealText(word);
287

  
288
		if (StringNumberUtilities.isRealNumber(word)) {
289
			ShowText.showYes();
290
		}
291
		else {
292
			ShowText.showNo();
293
			fail();
294
		}
295
	}
296
	
297
	/**
298
	 * A test
299
	 */
300
	public void test15() {
301
		word = "-4.6";
302
		ShowText.showIsRealText(word);
303

  
304
		if (StringNumberUtilities.isRealNumber(word)) {
305
			ShowText.showYes();
306
		}
307
		else {
308
			ShowText.showNo();
309
			fail();
310
		}
311
	}
312
	
313
	/**
314
	 * A test
315
	 */
316
	public void test16() {
317
		word = "-8000";
318
		ShowText.showIsRealText(word);
319

  
320
		if (StringNumberUtilities.isRealNumber(word)) {
321
			ShowText.showYes();
322
		}
323
		else {
324
			ShowText.showNo();
325
			fail();
326
		}
327
	}
328

  
329
	/**
330
	 * A test
331
	 */
332
	public void test17() {
333
		word = "-80k00";
334
		ShowText.showIsRealText(word);
335

  
336
		if (StringNumberUtilities.isRealNumber(word)) {
337
			ShowText.showYes();
338
		}
339
		else {
340
			ShowText.showNo();
341
			fail();
342
		}
343
	}
344
		
345
	/**
346
	 * A test
347
	 */
348
	public void test18() {
349
		word = ".6";
350
		ShowText.showIsRealText(word);
351

  
352
		if (StringNumberUtilities.isRealNumber(word)) {
353
			ShowText.showYes();
354
		}
355
		else {
356
			ShowText.showNo();
357
			fail();
358
		}
359
	}
360
	
361
	/**
362
	 * A test
363
	 */
364
	public void test19() {
365
		word = "-.6";
366
		ShowText.showIsRealText(word);
367

  
368
		if (StringNumberUtilities.isRealNumber(word)) {
369
			ShowText.showYes();
370
		}
371
		else {
372
			ShowText.showNo();
373
			fail();
374
		}
375
	}
376
	
377
	/**
378
	 * A test
379
	 */
380
	public void test20() {
381
		word = "b-.6";
382
		ShowText.showIsRealText(word);
383

  
384
		if (StringNumberUtilities.isRealNumber(word)) {
385
			ShowText.showYes();
386
		}
387
		else {
388
			ShowText.showNo();
389
			fail();
390
		}
391
	}
392
	
393
	
394
	/**
395
	 * A test
396
	 */
397
	public void test21() {
398
		word = "-c.6";
399
		ShowText.showIsRealText(word);
400

  
401
		if (StringNumberUtilities.isRealNumber(word)) {
402
			ShowText.showYes();
403
		}
404
		else {
405
			ShowText.showNo();
406
			fail();
407
		}
408
	}
409
	
410
	
411
	/**
412
	 * A test
413
	 */
414
	public void test22() {
415
		word = "-.d6";
416
		ShowText.showIsRealText(word);
417

  
418
		if (StringNumberUtilities.isRealNumber(word)) {
419
			ShowText.showYes();
420
		}
421
		else {
422
			ShowText.showNo();
423
			fail();
424
		}
425
	}
426
	
427
	/**
428
	 * A test
429
	 */
430
	public void test23() {
431
		word = "-.6e";
432
		ShowText.showIsRealText(word);
433

  
434
		if (StringNumberUtilities.isRealNumber(word)) {
435
			ShowText.showYes();
436
		}
437
		else {
438
			ShowText.showNo();
439
			fail();
440
		}
441
	}
442
	
443
	/**
444
	 * A test
445
	 */
446
	public void test24() {
447
		word = "+.6";
448
		ShowText.showIsRealText(word);
449

  
450
		if (StringNumberUtilities.isRealNumber(word)) {
451
			ShowText.showYes();
452
		}
453
		else {
454
			ShowText.showNo();
455
			fail();
456
		}
457
	}
458
	
459
	/**
460
	 * A test
461
	 */
462
	public void test25() {
463
		word = "+.6";
464
		ShowText.showIsRealWithIntegerExponentText(word);
465

  
466
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
467
			ShowText.showYes();
468
		}
469
		else {
470
			ShowText.showNo();
471
			fail();
472
		}
473
	}
474
	
475
	
476
	/**
477
	 * A test
478
	 */
479
	public void test26() {
480
		word = ".6";
481
		ShowText.showIsRealWithIntegerExponentText(word);
482

  
483
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
484
			ShowText.showYes();
485
		}
486
		else {
487
			ShowText.showNo();
488
			fail();
489
		}
490
	}
491

  
492
	
493
	/**
494
	 * A test
495
	 */
496
	public void test27() {
497
		word = "-.6";
498
		ShowText.showIsRealWithIntegerExponentText(word);
499

  
500
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
501
			ShowText.showYes();
502
		}
503
		else {
504
			ShowText.showNo();
505
			fail();
506
		}
507
	}
508

  
509
	
510
	/**
511
	 * A test
512
	 */
513
	public void test28() {
514
		word = "+6";
515
		ShowText.showIsRealWithIntegerExponentText(word);
516

  
517
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
518
			ShowText.showYes();
519
		}
520
		else {
521
			ShowText.showNo();
522
			fail();
523
		}
524
	}
525

  
526
	
527
	/**
528
	 * A test
529
	 */
530
	public void test29() {
531
		word = "-6";
532
		ShowText.showIsRealWithIntegerExponentText(word);
533

  
534
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
535
			ShowText.showYes();
536
		}
537
		else {
538
			ShowText.showNo();
539
			fail();
540
		}
541
	}
542

  
543
	
544
	/**
545
	 * A test
546
	 */
547
	public void test30() {
548
		word = "6";
549
		ShowText.showIsRealWithIntegerExponentText(word);
550

  
551
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
552
			ShowText.showYes();
553
		}
554
		else {
555
			ShowText.showNo();
556
			fail();
557
		}
558
	}
559
	
560
	/**
561
	 * A test
562
	 */
563
	public void test31() {
564
		word = "136.13";
565
		ShowText.showIsRealWithIntegerExponentText(word);
566

  
567
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
568
			ShowText.showYes();
569
		}
570
		else {
571
			ShowText.showNo();
572
			fail();
573
		}
574
	}
575
	
576
	
577
	/**
578
	 * A test
579
	 */
580
	public void test32() {
581
		word = "+13.42";
582
		ShowText.showIsRealWithIntegerExponentText(word);
583

  
584
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
585
			ShowText.showYes();
586
		}
587
		else {
588
			ShowText.showNo();
589
			fail();
590
		}
591
	}
592
	
593
	/**
594
	 * A test
595
	 */
596
	public void test33() {
597
		word = "-246.24";
598
		ShowText.showIsRealWithIntegerExponentText(word);
599

  
600
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
601
			ShowText.showYes();
602
		}
603
		else {
604
			ShowText.showNo();
605
			fail();
606
		}
607
	}
608
	
609
	/**
610
	 * A test
611
	 */
612
	public void test34() {
613
		word = "146.134E+13";
614
		ShowText.showIsRealWithIntegerExponentText(word);
615

  
616
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
617
			ShowText.showYes();
618
		}
619
		else {
620
			ShowText.showNo();
621
			fail();
622
		}
623
	}
624
	
625
	/**
626
	 * A test
627
	 */
628
	public void test35() {
629
		word = "614.425E-67";
630
		ShowText.showIsRealWithIntegerExponentText(word);
631

  
632
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
633
			ShowText.showYes();
634
		}
635
		else {
636
			ShowText.showNo();
637
			fail();
638
		}
639
	}
640
	
641
	/**
642
	 * A test
643
	 */
644
	public void test36() {
645
		word = "-8945.1201e48.141";
646
		ShowText.showIsRealWithIntegerExponentText(word);
647

  
648
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
649
			ShowText.showYes();
650
		}
651
		else {
652
			ShowText.showNo();
653
			fail();
654
		}
655
	}
656
	
657
	/**
658
	 * A test
659
	 */
660
	public void test37() {
661
		word = "-8945.1201e48.141.";
662
		ShowText.showIsRealWithIntegerExponentText(word);
663

  
664
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
665
			ShowText.showYes();
666
		}
667
		else {
668
			ShowText.showNo();
669
			fail();
670
		}
671
	}
672
	
673
	/**
674
	 * A test
675
	 */
676
	public void test38() {
677
		word = "8945.1201ee48.141";
678
		ShowText.showIsRealWithIntegerExponentText(word);
679

  
680
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
681
			ShowText.showYes();
682
		}
683
		else {
684
			ShowText.showNo();
685
			fail();
686
		}
687
	}
688
		
689
	/**
690
	 * A test
691
	 */
692
	public void test39() {
693
		word = "8945.1201E";
694
		ShowText.showIsRealWithIntegerExponentText(word);
695

  
696
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
697
			ShowText.showYes();
698
		}
699
		else {
700
			ShowText.showNo();
701
			fail();
702
		}
703
	}
704
	
705
	/**
706
	 * A test
707
	 */
708
	public void test40() {
709
		word = "8945.1201e+";
710
		ShowText.showIsRealWithIntegerExponentText(word);
711

  
712
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
713
			ShowText.showYes();
714
		}
715
		else {
716
			ShowText.showNo();
717
			fail();
718
		}
719
	}
720
	
721
	/**
722
	 * A test
723
	 */
724
	public void test41() {
725
		word = "8945.1201e+1";
726
		ShowText.showIsRealWithIntegerExponentText(word);
727

  
728
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
729
			ShowText.showYes();
730
		}
731
		else {
732
			ShowText.showNo();
733
			fail();
734
		}
735
	}
736
	
737
	
738
	/**
739
	 * A test
740
	 */
741
	public void test42() {
742
		word = "8945.1201e+.32";
743
		ShowText.showIsRealWithIntegerExponentText(word);
744

  
745
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
746
			ShowText.showYes();
747
		}
748
		else {
749
			ShowText.showNo();
750
			fail();
751
		}
752
	}
753
	
754
	/**
755
	 * A test
756
	 */
757
	public void test43() {
758
		word = "+.6";
759
		ShowText.showIsRealWithRealExponentText(word);
760

  
761
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
762
			ShowText.showYes();
763
		}
764
		else {
765
			ShowText.showNo();
766
			fail();
767
		}
768
	}
769
	
770
	
771
	/**
772
	 * A test
773
	 */
774
	public void test44() {
775
		word = ".6";
776
		ShowText.showIsRealWithRealExponentText(word);
777

  
778
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
779
			ShowText.showYes();
780
		}
781
		else {
782
			ShowText.showNo();
783
			fail();
784
		}
785
	}
786

  
787
	
788
	/**
789
	 * A test
790
	 */
791
	public void test45() {
792
		word = "-.6";
793
		ShowText.showIsRealWithRealExponentText(word);
794

  
795
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
796
			ShowText.showYes();
797
		}
798
		else {
799
			ShowText.showNo();
800
			fail();
801
		}
802
	}
803

  
804
	
805
	/**
806
	 * A test
807
	 */
808
	public void test46() {
809
		word = "+6";
810
		ShowText.showIsRealWithRealExponentText(word);
811

  
812
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
813
			ShowText.showYes();
814
		}
815
		else {
816
			ShowText.showNo();
817
			fail();
818
		}
819
	}
820

  
821
	
822
	/**
823
	 * A test
824
	 */
825
	public void test47() {
826
		word = "-6";
827
		ShowText.showIsRealWithRealExponentText(word);
828

  
829
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
830
			ShowText.showYes();
831
		}
832
		else {
833
			ShowText.showNo();
834
			fail();
835
		}
836
	}
837

  
838
	
839
	/**
840
	 * A test
841
	 */
842
	public void test48() {
843
		word = "6";
844
		ShowText.showIsRealWithRealExponentText(word);
845

  
846
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
847
			ShowText.showYes();
848
		}
849
		else {
850
			ShowText.showNo();
851
			fail();
852
		}
853
	}
854
	
855
	/**
856
	 * A test
857
	 */
858
	public void test49() {
859
		word = "136.13";
860
		ShowText.showIsRealWithRealExponentText(word);
861

  
862
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
863
			ShowText.showYes();
864
		}
865
		else {
866
			ShowText.showNo();
867
			fail();
868
		}
869
	}
870
	
871
	
872
	/**
873
	 * A test
874
	 */
875
	public void test50() {
876
		word = "+13.42";
877
		ShowText.showIsRealWithRealExponentText(word);
878

  
879
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
880
			ShowText.showYes();
881
		}
882
		else {
883
			ShowText.showNo();
884
			fail();
885
		}
886
	}
887
	
888
	/**
889
	 * A test
890
	 */
891
	public void test51() {
892
		word = "-246.24";
893
		ShowText.showIsRealWithRealExponentText(word);
894

  
895
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
896
			ShowText.showYes();
897
		}
898
		else {
899
			ShowText.showNo();
900
			fail();
901
		}
902
	}
903
	
904
	/**
905
	 * A test
906
	 */
907
	public void test52() {
908
		word = "146.134E+13";
909
		ShowText.showIsRealWithRealExponentText(word);
910

  
911
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
912
			ShowText.showYes();
913
		}
914
		else {
915
			ShowText.showNo();
916
			fail();
917
		}
918
	}
919
	
920
	/**
921
	 * A test
922
	 */
923
	public void test53() {
924
		word = "614.425E-67";
925
		ShowText.showIsRealWithRealExponentText(word);
926

  
927
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
928
			ShowText.showYes();
929
		}
930
		else {
931
			ShowText.showNo();
932
			fail();
933
		}
934
	}
935
	
936
	/**
937
	 * A test
938
	 */
939
	public void test54() {
940
		word = "-8945.1201e48.141";
941
		ShowText.showIsRealWithRealExponentText(word);
942

  
943
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
944
			ShowText.showYes();
945
		}
946
		else {
947
			ShowText.showNo();
948
			fail();
949
		}
950
	}
951
	
952
	/**
953
	 * A test
954
	 */
955
	public void test55() {
956
		word = "-8945.1201e48.141.";
957
		ShowText.showIsRealWithRealExponentText(word);
958

  
959
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
960
			ShowText.showYes();
961
		}
962
		else {
963
			ShowText.showNo();
964
			fail();
965
		}
966
	}
967
	
968
	/**
969
	 * A test
970
	 */
971
	public void test56() {
972
		word = "8945.1201ee48.141";
973
		ShowText.showIsRealWithRealExponentText(word);
974

  
975
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
976
			ShowText.showYes();
977
		}
978
		else {
979
			ShowText.showNo();
980
			fail();
981
		}
982
	}
983
		
984
	/**
985
	 * A test
986
	 */
987
	public void test57() {
988
		word = "8945.1201E";
989
		ShowText.showIsRealWithRealExponentText(word);
990

  
991
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
992
			ShowText.showYes();
993
		}
994
		else {
995
			ShowText.showNo();
996
			fail();
997
		}
998
	}
999
	
1000
	/**
1001
	 * A test
1002
	 */
1003
	public void test58() {
1004
		word = "8945.1201e+";
1005
		ShowText.showIsRealWithRealExponentText(word);
1006

  
1007
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
1008
			ShowText.showYes();
1009
		}
1010
		else {
1011
			ShowText.showNo();
1012
			fail();
1013
		}
1014
	}
1015
	
1016
	/**
1017
	 * A test
1018
	 */
1019
	public void test59() {
1020
		word = "8945.1201e+1";
1021
		ShowText.showIsRealWithRealExponentText(word);
1022

  
1023
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
1024
			ShowText.showYes();
1025
		}
1026
		else {
1027
			ShowText.showNo();
1028
			fail();
1029
		}
1030
	}
1031
	
1032
	/**
1033
	 * A test
1034
	 */
1035
	public void test60() {
1036
		word = "8945.1201e+.32";
1037
		ShowText.showIsRealWithRealExponentText(word);
1038

  
1039
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
1040
			ShowText.showYes();
1041
		}
1042
		else {
1043
			ShowText.showNo();
1044
			fail();
1045
		}
1046
	}
1047

  
1048
	/**
1049
	 * A test
1050
	 */
1051
	public void test61() {
1052
		word = "-";
1053
		ShowText.showIsIntegerText(word);
1054

  
1055
		if (StringNumberUtilities.isIntegerNumber(word)) {
1056
			ShowText.showYes();
1057
		}
1058
		else {
1059
			ShowText.showNo();
1060
			fail();
1061
		}
1062
	}
1063
	
1064
	/**
1065
	 * A test
1066
	 */
1067
	public void test62() {
1068
		word = "-";
1069
		ShowText.showIsNaturalText(word);
1070

  
1071
		if (StringNumberUtilities.isNaturalNumber(word)) {
1072
			ShowText.showYes();
1073
		}
1074
		else {
1075
			ShowText.showNo();
1076
			fail();
1077
		}
1078
	}
1079
	
1080
	/**
1081
	 * A test
1082
	 */
1083
	public void test63() {
1084
		word = "-";
1085
		ShowText.showIsNumberText(word);
1086

  
1087
		if (StringNumberUtilities.isNumber(word)) {
1088
			ShowText.showYes();
1089
		}
1090
		else {
1091
			ShowText.showNo();
1092
			fail();
1093
		}
1094
	}
1095
	
1096
	/**
1097
	 * A test
1098
	 */
1099
	public void test64() {
1100
		word = "-";
1101
		ShowText.showIsRealText(word);
1102

  
1103
		if (StringNumberUtilities.isRealNumber(word)) {
1104
			ShowText.showYes();
1105
		}
1106
		else {
1107
			ShowText.showNo();
1108
			fail();
1109
		}
1110
	}
1111
	
1112
	/**
1113
	 * A test
1114
	 */
1115
	public void test65() {
1116
		word = "-";
1117
		ShowText.showIsRealWithIntegerExponentText(word);
1118

  
1119
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
1120
			ShowText.showYes();
1121
		}
1122
		else {
1123
			ShowText.showNo();
1124
			fail();
1125
		}
1126
	}
1127
	
1128
	/**
1129
	 * A test
1130
	 */
1131
	public void test66() {
1132
		word = "-";
1133
		ShowText.showIsRealWithRealExponentText(word);
1134

  
1135
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
1136
			ShowText.showYes();
1137
		}
1138
		else {
1139
			ShowText.showNo();
1140
			fail();
1141
		}
1142
	}
1143

  
1144
	/**
1145
	 * A test
1146
	 */
1147
	public void test67() {
1148
		word = "+";
1149
		ShowText.showIsIntegerText(word);
1150

  
1151
		if (StringNumberUtilities.isIntegerNumber(word)) {
1152
			ShowText.showYes();
1153
		}
1154
		else {
1155
			ShowText.showNo();
1156
			fail();
1157
		}
1158
	}
1159
	
1160
	/**
1161
	 * A test
1162
	 */
1163
	public void test68() {
1164
		word = "+";
1165
		ShowText.showIsNaturalText(word);
1166

  
1167
		if (StringNumberUtilities.isNaturalNumber(word)) {
1168
			ShowText.showYes();
1169
		}
1170
		else {
1171
			ShowText.showNo();
1172
			fail();
1173
		}
1174
	}
1175
	
1176
	/**
1177
	 * A test
1178
	 */
1179
	public void test69() {
1180
		word = "+";
1181
		ShowText.showIsNumberText(word);
1182

  
1183
		if (StringNumberUtilities.isNumber(word)) {
1184
			ShowText.showYes();
1185
		}
1186
		else {
1187
			ShowText.showNo();
1188
			fail();
1189
		}
1190
	}
1191
	
1192
	/**
1193
	 * A test
1194
	 */
1195
	public void test70() {
1196
		word = "+";
1197
		ShowText.showIsRealText(word);
1198

  
1199
		if (StringNumberUtilities.isRealNumber(word)) {
1200
			ShowText.showYes();
1201
		}
1202
		else {
1203
			ShowText.showNo();
1204
			fail();
1205
		}
1206
	}
1207
	
1208
	/**
1209
	 * A test
1210
	 */
1211
	public void test71() {
1212
		word = "+";
1213
		ShowText.showIsRealWithIntegerExponentText(word);
1214

  
1215
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
1216
			ShowText.showYes();
1217
		}
1218
		else {
1219
			ShowText.showNo();
1220
			fail();
1221
		}
1222
	}
1223
	
1224
	/**
1225
	 * A test
1226
	 */
1227
	public void test72() {
1228
		word = "+";
1229
		ShowText.showIsRealWithRealExponentText(word);
1230

  
1231
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
1232
			ShowText.showYes();
1233
		}
1234
		else {
1235
			ShowText.showNo();
1236
			fail();
1237
		}
1238
	}
1239

  
1240
	/**
1241
	 * Shows a text sentence
1242
	 * 
1243
	 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
1244
	 */
1245
	private static class ShowText {
1246
		/**
1247
		 * Shows the text: Is number?
1248
		 * 
1249
		 * @param word An String
1250
		 */
1251
		public static void showIsNumberText(String word) {
1252
			System.out.print("? Es n?mero \'" + word + "\' ? ");
1253
		}
1254

  
1255
		/**
1256
		 * Shows the text: Is natural number?
1257
		 * 
1258
		 * @param word An String
1259
		 */
1260
		public static void showIsNaturalText(String word) {
1261
			System.out.print("? Es n?mero natural \'" + word + "\' ? ");
1262
		}
1263

  
1264
		/**
1265
		 * Shows the text: Is integer number?
1266
		 * 
1267
		 * @param word An String
1268
		 */
1269
		public static void showIsIntegerText(String word) {
1270
			System.out.print("? Es n?mero entero \'" + word + "\' ? ");
1271
		}
1272

  
1273
		/**
1274
		 * Shows the text: Is rational number?
1275
		 * 
1276
		 * @param word An String
1277
		 */
1278
		public static void showIsRealText(String word) {
1279
			System.out.print("? Es n?mero real \'" + word + "\' ? ");
1280
		}
1281
		
1282
		/**
1283
		 * Shows the text: Is integer exponent rational number?
1284
		 * 
1285
		 * @param word An String
1286
		 */
1287
		public static void showIsRealWithIntegerExponentText(String word) {
1288
			System.out.print("? Es n?mero real con exponente entero \'" + word + "\' ? ");
1289
		}
1290
		
1291
		/**
1292
		 * Shows the text: Is rational exponent rational number?
1293
		 * 
1294
		 * @param word An String
1295
		 */
1296
		public static void showIsRealWithRealExponentText(String word) {
1297
			System.out.print("? Es n?mero real con exponente real \'" + word + "\' ? ");
1298
		}
1299

  
1300
		/**
1301
		 * Shows the text: Yes
1302
		 * 
1303
		 * @param word An String
1304
		 */
1305
		public static void showYes() {
1306
			System.out.println("Si.");
1307
		}
1308
		
1309
		/**
1310
		 * Shows the text: No
1311
		 * 
1312
		 * @param word An String
1313
		 */
1314
		public static void showNo() {
1315
			System.out.println("No.");
1316
		}
1317
	}
1318
}
0 1319

  
tags/v2_0_0_Build_2047/libraries/libIverUtiles/src-test/org/gvsig/utils/TestXMLEntity.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41

  
42
/* CVS MESSAGES:
43
*
44
* $Id$
45
* $Log$
46
* Revision 1.7  2007-03-05 11:15:43  jaume
47
* *** empty log message ***
48
*
49
* Revision 1.6  2007/03/05 10:03:12  jaume
50
* *** empty log message ***
51
*
52
* Revision 1.5  2007/03/05 09:00:11  jaume
53
* *** empty log message ***
54
*
55
* Revision 1.4  2007/03/02 13:35:56  jaume
56
* *** empty log message ***
57
*
58
* Revision 1.3  2007/03/02 13:27:32  jaume
59
* *** empty log message ***
60
*
61
* Revision 1.2  2007/03/02 13:24:53  jaume
62
* *** empty log message ***
63
*
64
* Revision 1.1  2007/03/02 13:23:50  jaume
65
* *** empty log message ***
66
*
67
* Revision 1.1  2006/08/29 06:18:17  jaume
68
* *** empty log message ***
69
*
70
*
71
*/
72
package org.gvsig.utils;
73

  
74
import java.io.File;
75
import java.io.FileReader;
76

  
77
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
78
import org.gvsig.utils.xmlEntity.generate.XmlTag;
79

  
80

  
81
public class TestXMLEntity extends AbstractLibraryAutoInitTestCase {
82
	private XMLEntity x1, x2, x3, x4;
83
	private XMLEntity gvp1;
84
	private XMLEntity gvp2;
85

  
86
	@Override
87
	protected void doSetUp() throws Exception {
88

  
89
		x1 = new XMLEntity();
90
		x2 = new XMLEntity();
91
		x3 = new XMLEntity();
92

  
93
		
94
		final Object obj1 = new XMLEntity();
95
		final Object obj2 = new XMLEntity();
96
		final Object obj3 = "StringClass";
97

  
98
		
99
		x1.putProperty("boolean1", false);
100
		x1.putProperty("boolean2", true);
101

  
102
		x1.putProperty("integer1", Integer.parseInt("123"));
103
		x1.putProperty("integer2", Integer.parseInt("321"));
104

  
105
		x1.putProperty("long1", Long.parseLong("123123"));
106
		x1.putProperty("long2", Long.parseLong("321321"));
107

  
108
		x1.putProperty("float1", Float.parseFloat("1234.1234"));
109
		x1.putProperty("float2", Float.parseFloat("4321.4321"));
110

  
111
		x1.putProperty("double1", Double.parseDouble("12341234.12341234"));
112
		x1.putProperty("double2", Double.parseDouble("43214321.43214321"));
113

  
114
		x1.putProperty("string1", "String1");
115
		x1.putProperty("string2", "String2");
116

  
117
		x1.putProperty("object1", obj1);
118
		x1.putProperty("object2", obj2);
119

  
120

  
121
		//----- x1 == x2
122
		x2.putProperty("boolean1", false);
123
		x2.putProperty("boolean2", true);
124

  
125
		x2.putProperty("integer1", Integer.parseInt("123"));
126
		x2.putProperty("integer2", Integer.parseInt("321"));
127

  
128
		x2.putProperty("long1", Long.parseLong("123123"));
129
		x2.putProperty("long2", Long.parseLong("321321"));
130

  
131
		x2.putProperty("float1", Float.parseFloat("1234.1234"));
132
		x2.putProperty("float2", Float.parseFloat("4321.4321"));
133

  
134
		x2.putProperty("double1", Double.parseDouble("12341234.12341234"));
135
		x2.putProperty("double2", Double.parseDouble("43214321.43214321"));
136

  
137
		x2.putProperty("string1", "String1");
138
		x2.putProperty("string2", "String2");
139

  
140
		x2.putProperty("object1", obj1);
141
		x2.putProperty("object2", obj2);
142

  
143
		
144
		//----- x1 != x3
145

  
146
		x3.putProperty("boolean1", false);
147
		x3.putProperty("boolean2", true);
148

  
149
		x3.putProperty("integer1", Integer.parseInt("123"));
150
		x3.putProperty("integer2", Integer.parseInt("321"));
151

  
152
		x3.putProperty("long1", Long.parseLong("123123"));
153
		x3.putProperty("long2", Long.parseLong("321321"));
154

  
155
		x3.putProperty("float1", Float.parseFloat("1234.1234"));
156
		x3.putProperty("float2", Float.parseFloat("4321.4321"));
157

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff