KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sablecc > sablecc > alphabet > SymbolTest


1 /* This file is part of SableCC ( http://sablecc.org ).
2  *
3  * Copyright 2007 Raymond Audet <raymond.audet@gmail.com>
4  * Copyright 2007 Etienne M. Gagnon <egagnon@j-meg.com>
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 package org.sablecc.sablecc.alphabet;
20
21 import static org.junit.Assert.assertEquals;
22 import static org.junit.Assert.assertFalse;
23 import static org.junit.Assert.assertTrue;
24 import static org.junit.Assert.fail;
25
26 import java.math.BigInteger JavaDoc;
27 import java.util.Collection JavaDoc;
28 import java.util.LinkedList JavaDoc;
29
30 import org.junit.Before;
31 import org.junit.Test;
32 import org.sablecc.sablecc.exception.InternalException;
33
34 public class SymbolTest {
35
36     private Symbol<Integer JavaDoc> symbolInt;
37
38     private Collection JavaDoc<Interval<Integer JavaDoc>> intervalsInt = new LinkedList JavaDoc<Interval<Integer JavaDoc>>();
39
40     private Symbol<BigInteger JavaDoc> symbolBig;
41
42     private Collection JavaDoc<Interval<BigInteger JavaDoc>> intervalsBig = new LinkedList JavaDoc<Interval<BigInteger JavaDoc>>();
43
44     @Before
45     public void setUp()
46             throws Exception JavaDoc {
47
48         // For Integer.
49
this.intervalsInt.clear();
50         this.intervalsInt
51                 .add(new Interval<Integer JavaDoc>(10, 20, Realms.getInteger()));
52         this.intervalsInt.add(new Interval<Integer JavaDoc>(50, 100, Realms
53                 .getInteger()));
54         this.intervalsInt.add(new Interval<Integer JavaDoc>(200, 400, Realms
55                 .getInteger()));
56
57         this.symbolInt = new Symbol<Integer JavaDoc>(this.intervalsInt);
58
59         // For BigInteger.
60
this.intervalsBig.clear();
61         this.intervalsBig.add(new Interval<BigInteger JavaDoc>(BigInteger.ZERO,
62                 BigInteger.TEN, Realms.getBigInteger()));
63         this.intervalsBig.add(new Interval<BigInteger JavaDoc>(new BigInteger JavaDoc("50"),
64                 new BigInteger JavaDoc("100"), Realms.getBigInteger()));
65         this.intervalsBig.add(new Interval<BigInteger JavaDoc>(new BigInteger JavaDoc("200"),
66                 new BigInteger JavaDoc("400"), Realms.getBigInteger()));
67
68         this.symbolBig = new Symbol<BigInteger JavaDoc>(this.intervalsBig);
69     }
70
71     @Test
72     public void testGetIntervals() {
73
74         // Case with complement symbol
75
this.symbolInt = new Symbol<Integer JavaDoc>();
76         try {
77             this.symbolInt.getIntervals();
78             fail("complement symbols have no intervals");
79         }
80         catch (InternalException e) {
81             // Expected
82
}
83     }
84
85     @Test
86     public void testHashCode() {
87
88         // For Integer.
89
Symbol<Integer JavaDoc> sameSymbolInt = new Symbol<Integer JavaDoc>(this.intervalsInt);
90         assertEquals(
91                 "Two instance of the same symbol should have the same hashcode",
92                 this.symbolInt.hashCode(), sameSymbolInt.hashCode());
93
94         // For BigInteger.
95
Symbol<BigInteger JavaDoc> sameSymbolBig = new Symbol<BigInteger JavaDoc>(
96                 this.intervalsBig);
97         assertEquals(
98                 "Two instance of the same symbol should have the same hashcode",
99                 this.symbolBig.hashCode(), sameSymbolBig.hashCode());
100     }
101
102     @SuppressWarnings JavaDoc("unused")
103     @Test
104     public void testSymbolCollectionOfIntervalOfT() {
105
106         // Case with null collection.
107
Collection JavaDoc<Interval<Integer JavaDoc>> intervalsNull = null;
108
109         try {
110             Symbol<Integer JavaDoc> symbolNullCollection = new Symbol<Integer JavaDoc>(
111                     intervalsNull);
112
113             fail("An InternalException should be thrown.");
114         }
115         catch (InternalException e) {
116             // expected
117
}
118
119         // Case with empty collection.
120
Collection JavaDoc<Interval<Integer JavaDoc>> intervalsEmpty = new LinkedList JavaDoc<Interval<Integer JavaDoc>>();
121
122         try {
123             Symbol<Integer JavaDoc> symbolEmptyCollection = new Symbol<Integer JavaDoc>(
124                     intervalsEmpty);
125
126             fail("an InternalException should be thrown");
127         }
128         catch (InternalException e) {
129             // excepted
130
}
131
132         // Case with collection having a null interval.
133
Collection JavaDoc<Interval<Integer JavaDoc>> intervalsNullInterval = new LinkedList JavaDoc<Interval<Integer JavaDoc>>();
134
135         try {
136             intervalsNullInterval.add(new Interval<Integer JavaDoc>(null, Realms
137                     .getInteger()));
138
139             fail("an InternalException should be thrown");
140         }
141         catch (InternalException e) {
142             // expected
143
}
144
145         // Case with collection having intersecting intervals with Integer.
146
Collection JavaDoc<Interval<Integer JavaDoc>> intervalsIntersectingIntervalsInt = new LinkedList JavaDoc<Interval<Integer JavaDoc>>();
147         intervalsIntersectingIntervalsInt.add(new Interval<Integer JavaDoc>(0, 50,
148                 Realms.getInteger()));
149         intervalsIntersectingIntervalsInt.add(new Interval<Integer JavaDoc>(25, 999,
150                 Realms.getInteger()));
151
152         try {
153             Symbol<Integer JavaDoc> symbolIntersectingIntervalsInt = new Symbol<Integer JavaDoc>(
154                     intervalsIntersectingIntervalsInt);
155             fail("An InternalException should be thrown.");
156         }
157         catch (InternalException e) {
158             // expected
159
}
160
161         // Case with collection having intersecting intervals with BigInteger.
162
Collection JavaDoc<Interval<BigInteger JavaDoc>> intervalsIntersectingIntervalsBig = new LinkedList JavaDoc<Interval<BigInteger JavaDoc>>();
163         intervalsIntersectingIntervalsBig.add(new Interval<BigInteger JavaDoc>(
164                 new BigInteger JavaDoc("0"), new BigInteger JavaDoc("50"), Realms
165                         .getBigInteger()));
166         intervalsIntersectingIntervalsBig.add(new Interval<BigInteger JavaDoc>(
167                 new BigInteger JavaDoc("25"), new BigInteger JavaDoc("999"), Realms
168                         .getBigInteger()));
169
170         try {
171             Symbol<BigInteger JavaDoc> symbolIntersectingIntervalsBig = new Symbol<BigInteger JavaDoc>(
172                     intervalsIntersectingIntervalsBig);
173             fail("An InternalException should be thrown.");
174         }
175         catch (InternalException e) {
176             // expected
177
}
178
179         // Case with collection having adjacent intervals using Integer.
180
Collection JavaDoc<Interval<Integer JavaDoc>> intervalsAdjacentIntervalsInt = new LinkedList JavaDoc<Interval<Integer JavaDoc>>();
181         intervalsAdjacentIntervalsInt.add(new Interval<Integer JavaDoc>(0, 10, Realms
182                 .getInteger()));
183         intervalsAdjacentIntervalsInt.add(new Interval<Integer JavaDoc>(11, 30, Realms
184                 .getInteger()));
185         intervalsAdjacentIntervalsInt.add(new Interval<Integer JavaDoc>(31, 40, Realms
186                 .getInteger()));
187         Symbol<Integer JavaDoc> symbolAdjacentIntervalsInt = new Symbol<Integer JavaDoc>(
188                 intervalsAdjacentIntervalsInt);
189
190         assertTrue(
191                 "there should be only this interval in the symbol :[0..40].",
192                 symbolAdjacentIntervalsInt.getIntervals().size() == 1);
193
194         // Case with collecting having adjacent intervals using BigInteger.
195
Collection JavaDoc<Interval<BigInteger JavaDoc>> intervalsAdjacentIntervalsBig = new LinkedList JavaDoc<Interval<BigInteger JavaDoc>>();
196         intervalsAdjacentIntervalsBig.add(new Interval<BigInteger JavaDoc>(
197                 BigInteger.ZERO, BigInteger.ONE, Realms.getBigInteger()));
198         intervalsAdjacentIntervalsBig.add(new Interval<BigInteger JavaDoc>(
199                 new BigInteger JavaDoc("2"), BigInteger.TEN, Realms.getBigInteger()));
200         intervalsAdjacentIntervalsBig.add(new Interval<BigInteger JavaDoc>(
201                 new BigInteger JavaDoc("11"), new BigInteger JavaDoc("50"), Realms
202                         .getBigInteger()));
203         Symbol<BigInteger JavaDoc> symbolAdjacentIntervalsBig = new Symbol<BigInteger JavaDoc>(
204                 intervalsAdjacentIntervalsBig);
205
206         assertTrue(
207                 "There should be only this interval in the symbol :[0..50].",
208                 symbolAdjacentIntervalsBig.getIntervals().size() == 1);
209     }
210
211     @SuppressWarnings JavaDoc("unused")
212     @Test
213     public void testSymbolIntervalOfT() {
214
215         // Case with collection having a null interval.
216
Collection JavaDoc<Interval<Integer JavaDoc>> intervalsNullInterval = new LinkedList JavaDoc<Interval<Integer JavaDoc>>();
217
218         try {
219             intervalsNullInterval.add(new Interval<Integer JavaDoc>(null, Realms
220                     .getInteger()));
221
222             fail("An InternalException should be thrown.");
223         }
224         catch (InternalException e) {
225             // expected
226
}
227
228         // Typical Case using Integer.
229
Symbol<Integer JavaDoc> intervalsSingleIntervalInt = new Symbol<Integer JavaDoc>(
230                 new Interval<Integer JavaDoc>(10, 30, Realms.getInteger()));
231
232         assertTrue("There should be only one Interval in the symbol",
233                 intervalsSingleIntervalInt.getIntervals().size() == 1);
234
235         // Typical Case using BigInteger.
236
Symbol<BigInteger JavaDoc> intervalsSingleIntervalBig = new Symbol<BigInteger JavaDoc>(
237                 new Interval<BigInteger JavaDoc>(new BigInteger JavaDoc("1000"),
238                         new BigInteger JavaDoc("50000"), Realms.getBigInteger()));
239
240         assertTrue("There should be only one Interval in the symbol",
241                 intervalsSingleIntervalBig.getIntervals().size() == 1);
242     }
243
244     @Test
245     public void testEqualsObject() {
246
247         // Case with null object.
248
assertFalse("A symbol and a null Object should not be equals.",
249                 this.symbolInt.equals(null));
250
251         // Case with not an instance of symbol.
252
assertFalse(
253                 "A symbol and an object with instance other than Symbol should not be equals.",
254                 this.symbolInt.equals(2));
255
256         // Case with same symbols using Integer.
257
Symbol<Integer JavaDoc> sameSymbolInt = new Symbol<Integer JavaDoc>(this.intervalsInt);
258         assertTrue("The two symbols should be equals.", this.symbolInt
259                 .equals(sameSymbolInt));
260
261         // Case with same symbols using BigInteger.
262
Symbol<BigInteger JavaDoc> sameSymbolBig = new Symbol<BigInteger JavaDoc>(
263                 this.intervalsBig);
264         assertTrue("The two symbols should be equals.", this.symbolBig
265                 .equals(sameSymbolBig));
266
267         // Case with different symbol using Integer.
268
this.intervalsInt.add(new Interval<Integer JavaDoc>(500, 1000, Realms
269                 .getInteger()));
270         Symbol<Integer JavaDoc> differentSymbolInt = new Symbol<Integer JavaDoc>(
271                 this.intervalsInt);
272
273         assertFalse("Two symbols having different size should not be equals",
274                 this.symbolInt.equals(differentSymbolInt));
275
276         // Case with different symbol using BigInteger.
277
this.intervalsBig.add(new Interval<BigInteger JavaDoc>(new BigInteger JavaDoc("999"),
278                 new BigInteger JavaDoc("9999"), Realms.getBigInteger()));
279         Symbol<BigInteger JavaDoc> differentSymbolBig = new Symbol<BigInteger JavaDoc>(
280                 this.intervalsBig);
281
282         assertFalse("Two symbols having different size should not be equals",
283                 this.symbolBig.equals(differentSymbolBig));
284
285     }
286
287     @Test
288     public void testCompareTo() {
289
290         // Case with smaller symbol using Integer.
291
this.intervalsInt.clear();
292         this.intervalsInt
293                 .add(new Interval<Integer JavaDoc>(0, 10, Realms.getInteger()));
294         this.intervalsInt
295                 .add(new Interval<Integer JavaDoc>(30, 50, Realms.getInteger()));
296         this.intervalsInt.add(new Interval<Integer JavaDoc>(100, 200, Realms
297                 .getInteger()));
298         Symbol<Integer JavaDoc> smallerSymbolInt = new Symbol<Integer JavaDoc>(
299                 this.intervalsInt);
300
301         assertTrue("smallerSymbolInt should be smaller.", smallerSymbolInt
302                 .compareTo(this.symbolInt) < 0);
303
304         // Case with smaller symbol using BigInteger.
305
this.intervalsBig.clear();
306         this.intervalsBig.add(new Interval<BigInteger JavaDoc>(BigInteger.ZERO,
307                 BigInteger.ONE, Realms.getBigInteger()));
308         this.intervalsBig.add(new Interval<BigInteger JavaDoc>(new BigInteger JavaDoc("10"),
309                 new BigInteger JavaDoc("20"), Realms.getBigInteger()));
310         this.intervalsBig.add(new Interval<BigInteger JavaDoc>(new BigInteger JavaDoc("30"),
311                 new BigInteger JavaDoc("40"), Realms.getBigInteger()));
312
313         Symbol<BigInteger JavaDoc> smallerSymbolBig = new Symbol<BigInteger JavaDoc>(
314                 this.intervalsBig);
315
316         assertTrue("smallerSymbolBig should be smaller.", smallerSymbolBig
317                 .compareTo(this.symbolBig) < 0);
318
319         // Case with greater Symbol using Integer.
320
this.intervalsInt.clear();
321         this.intervalsInt.add(new Interval<Integer JavaDoc>(100, 200, Realms
322                 .getInteger()));
323         this.intervalsInt.add(new Interval<Integer JavaDoc>(500, 1000, Realms
324                 .getInteger()));
325         this.intervalsInt.add(new Interval<Integer JavaDoc>(2000, 4000, Realms
326                 .getInteger()));
327         Symbol<Integer JavaDoc> greaterSymbolInt = new Symbol<Integer JavaDoc>(
328                 this.intervalsInt);
329
330         assertTrue("greaterSymbolInt should be greater", greaterSymbolInt
331                 .compareTo(this.symbolInt) > 0);
332
333         // Case with greater symbol using BigInteger.
334
this.intervalsBig.clear();
335         this.intervalsBig.add(new Interval<BigInteger JavaDoc>(new BigInteger JavaDoc("30"),
336                 new BigInteger JavaDoc("40"), Realms.getBigInteger()));
337         this.intervalsBig.add(new Interval<BigInteger JavaDoc>(new BigInteger JavaDoc("120"),
338                 new BigInteger JavaDoc("180"), Realms.getBigInteger()));
339         this.intervalsBig.add(new Interval<BigInteger JavaDoc>(new BigInteger JavaDoc("500"),
340                 new BigInteger JavaDoc("99999"), Realms.getBigInteger()));
341
342         Symbol<BigInteger JavaDoc> greaterSymbolBig = new Symbol<BigInteger JavaDoc>(
343                 this.intervalsBig);
344
345         assertTrue("greaterSymbolBig should be greater.", greaterSymbolBig
346                 .compareTo(this.symbolBig) > 0);
347
348         // Case with equals symbol using Integer.
349
this.intervalsInt.clear();
350         this.intervalsInt
351                 .add(new Interval<Integer JavaDoc>(10, 20, Realms.getInteger()));
352         this.intervalsInt.add(new Interval<Integer JavaDoc>(50, 100, Realms
353                 .getInteger()));
354         this.intervalsInt.add(new Interval<Integer JavaDoc>(200, 400, Realms
355                 .getInteger()));
356
357         Symbol<Integer JavaDoc> sameSymbolInt = new Symbol<Integer JavaDoc>(this.intervalsInt);
358         assertTrue("The two symbols should be equals.", sameSymbolInt
359                 .compareTo(this.symbolInt) == 0);
360
361         // Case with equals symbol using BigInteger.
362
this.intervalsBig.clear();
363         this.intervalsBig.add(new Interval<BigInteger JavaDoc>(BigInteger.ZERO,
364                 BigInteger.TEN, Realms.getBigInteger()));
365         this.intervalsBig.add(new Interval<BigInteger JavaDoc>(new BigInteger JavaDoc("50"),
366                 new BigInteger JavaDoc("100"), Realms.getBigInteger()));
367         this.intervalsBig.add(new Interval<BigInteger JavaDoc>(new BigInteger JavaDoc("200"),
368                 new BigInteger JavaDoc("400"), Realms.getBigInteger()));
369
370         Symbol<BigInteger JavaDoc> sameSymbolBig = new Symbol<BigInteger JavaDoc>(
371                 this.intervalsBig);
372         assertTrue("The two symbols should be equals.", sameSymbolBig
373                 .compareTo(this.symbolBig) == 0);
374
375         // Case with complement symbol
376
Symbol<Integer JavaDoc> complementSymbol = new Symbol<Integer JavaDoc>();
377         assertEquals("the two complement Symbols should be equals", 0,
378                 complementSymbol.compareTo(new Symbol<Integer JavaDoc>()));
379
380         assertTrue("this symbol should be greater than a complement symbol",
381                 this.symbolInt.compareTo(complementSymbol) > 0);
382
383         assertTrue("this symbol should be greater than a complement symbol",
384                 complementSymbol.compareTo(this.symbolInt) < 0);
385
386     }
387
388     @SuppressWarnings JavaDoc("unused")
389     @Test
390     public void testMerge() {
391
392         // Case with null collection.
393
Collection JavaDoc<Symbol<Integer JavaDoc>> nullCollection = null;
394
395         try {
396             this.symbolInt = Symbol.merge(nullCollection);
397             fail("An InternalException should have been thrown");
398         }
399         catch (InternalException e) {
400             // expected
401
}
402
403         // Case with empty collection.
404
Collection JavaDoc<Symbol<Integer JavaDoc>> emptyCollection = new LinkedList JavaDoc<Symbol<Integer JavaDoc>>();
405
406         try {
407             this.symbolInt = Symbol.merge(nullCollection);
408             fail("An InternalException should have been thrown");
409         }
410         catch (InternalException e) {
411             // expected
412
}
413
414         // Case typical merging using Integer.
415
Collection JavaDoc<Symbol<Integer JavaDoc>> symbolCollectionInt = new LinkedList JavaDoc<Symbol<Integer JavaDoc>>();
416         symbolCollectionInt.add(this.symbolInt);
417         this.intervalsInt.add(new Interval<Integer JavaDoc>(500, 1000, Realms
418                 .getInteger()));
419         symbolCollectionInt.add(new Symbol<Integer JavaDoc>(this.intervalsInt));
420
421         Symbol<Integer JavaDoc> mergeSymbolInt = Symbol.merge(symbolCollectionInt);
422         assertTrue(
423                 "mergeSymbolInt should contain more elements than symbolInt",
424                 mergeSymbolInt.compareTo(this.symbolInt) > 0);
425
426         // Case typical merging using BigInteger.
427
Collection JavaDoc<Symbol<BigInteger JavaDoc>> symbolCollectionBig = new LinkedList JavaDoc<Symbol<BigInteger JavaDoc>>();
428         symbolCollectionBig.add(this.symbolBig);
429         this.intervalsBig.add(new Interval<BigInteger JavaDoc>(new BigInteger JavaDoc("500"),
430                 new BigInteger JavaDoc("1000"), Realms.getBigInteger()));
431         symbolCollectionBig.add(new Symbol<BigInteger JavaDoc>(this.intervalsBig));
432
433         Symbol<BigInteger JavaDoc> mergeSymbolBig = Symbol.merge(symbolCollectionBig);
434         assertTrue(
435                 "mergeSymbolBig should contain more elements than symbolBig",
436                 mergeSymbolBig.compareTo(this.symbolBig) > 0);
437
438         // Case with complement symbols
439
symbolCollectionInt.clear();
440         symbolCollectionInt.add(new Symbol<Integer JavaDoc>());
441         symbolCollectionInt.add(new Symbol<Integer JavaDoc>());
442         try {
443             Symbol.merge(symbolCollectionInt);
444             fail("multiple complement symbols may not be merged");
445         }
446         catch (InternalException e) {
447             // Expected
448
}
449     }
450
451     @Test
452     public void testMin() {
453
454         Symbol<Integer JavaDoc> resultSymbolInt;
455
456         Symbol<BigInteger JavaDoc> resultSymbolBig;
457
458         // Case with null symbol.
459
try {
460             resultSymbolInt = Symbol.min(this.symbolInt, null);
461             fail("An InternalException should have been thrown.");
462         }
463         catch (InternalException e) {
464             // expected
465
}
466
467         // Test typical min using Integer.
468
this.intervalsInt.clear();
469         this.intervalsInt
470                 .add(new Interval<Integer JavaDoc>(0, 10, Realms.getInteger()));
471         this.intervalsInt
472                 .add(new Interval<Integer JavaDoc>(30, 50, Realms.getInteger()));
473         this.intervalsInt.add(new Interval<Integer JavaDoc>(100, 200, Realms
474                 .getInteger()));
475         Symbol<Integer JavaDoc> smallerSymbolInt = new Symbol<Integer JavaDoc>(
476                 this.intervalsInt);
477
478         resultSymbolInt = Symbol.min(this.symbolInt, smallerSymbolInt);
479         assertTrue("smallerSymbolInt should be the min.", smallerSymbolInt
480                 .equals(resultSymbolInt));
481
482         // Test typical min using BigInteger.
483
this.intervalsBig.clear();
484         this.intervalsBig.add(new Interval<BigInteger JavaDoc>(BigInteger.ZERO,
485                 BigInteger.ONE, Realms.getBigInteger()));
486         this.intervalsBig.add(new Interval<BigInteger JavaDoc>(new BigInteger JavaDoc("10"),
487                 new BigInteger JavaDoc("20"), Realms.getBigInteger()));
488         this.intervalsBig.add(new Interval<BigInteger JavaDoc>(new BigInteger JavaDoc("30"),
489                 new BigInteger JavaDoc("40"), Realms.getBigInteger()));
490         Symbol<BigInteger JavaDoc> smallerSymbolBig = new Symbol<BigInteger JavaDoc>(
491                 this.intervalsBig);
492
493         resultSymbolBig = Symbol.min(this.symbolBig, smallerSymbolBig);
494         assertTrue("smallerSymbolBig should be the min.", smallerSymbolBig
495                 .equals(resultSymbolBig));
496
497     }
498
499     @Test
500     public void testMax() {
501
502         Symbol<Integer JavaDoc> resultSymbolInt;
503
504         Symbol<BigInteger JavaDoc> resultSymbolBig;
505
506         // Case with null symbol.
507
try {
508             resultSymbolInt = Symbol.max(this.symbolInt, null);
509             fail("An InternalException should have been thrown.");
510         }
511         catch (InternalException e) {
512             // expected
513
}
514
515         // Case typical use of max using Integer.
516
this.intervalsInt.clear();
517         this.intervalsInt.add(new Interval<Integer JavaDoc>(100, 200, Realms
518                 .getInteger()));
519         this.intervalsInt.add(new Interval<Integer JavaDoc>(500, 1000, Realms
520                 .getInteger()));
521         this.intervalsInt.add(new Interval<Integer JavaDoc>(2000, 4000, Realms
522                 .getInteger()));
523         Symbol<Integer JavaDoc> greaterSymbolInt = new Symbol<Integer JavaDoc>(
524                 this.intervalsInt);
525
526         resultSymbolInt = Symbol.max(this.symbolInt, greaterSymbolInt);
527         assertTrue("greaterSymbolInt should be the max.", greaterSymbolInt
528                 .equals(resultSymbolInt));
529
530         // Case typical use of max using BigInteger.
531
this.intervalsBig.clear();
532         this.intervalsBig.add(new Interval<BigInteger JavaDoc>(new BigInteger JavaDoc("30"),
533                 new BigInteger JavaDoc("40"), Realms.getBigInteger()));
534         this.intervalsBig.add(new Interval<BigInteger JavaDoc>(new BigInteger JavaDoc("120"),
535                 new BigInteger JavaDoc("180"), Realms.getBigInteger()));
536         this.intervalsBig.add(new Interval<BigInteger JavaDoc>(new BigInteger JavaDoc("500"),
537                 new BigInteger JavaDoc("99999"), Realms.getBigInteger()));
538         Symbol<BigInteger JavaDoc> greaterSymbolBig = new Symbol<BigInteger JavaDoc>(
539                 this.intervalsBig);
540
541         resultSymbolBig = Symbol.max(this.symbolBig, greaterSymbolBig);
542         assertTrue("greaterSymbolBig should be the max.", greaterSymbolBig
543                 .equals(resultSymbolBig));
544     }
545
546 }
547
Popular Tags