ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/TreeMapTest.java
(Generate patch)

Comparing jsr166/src/test/tck/TreeMapTest.java (file contents):
Revision 1.5 by dl, Sat Apr 19 18:45:18 2008 UTC vs.
Revision 1.8 by jsr166, Mon Nov 16 05:30:08 2009 UTC

# Line 11 | Line 11 | import java.io.*;
11  
12   public class TreeMapTest extends JSR166TestCase {
13      public static void main(String[] args) {
14 <        junit.textui.TestRunner.run (suite());  
14 >        junit.textui.TestRunner.run (suite());
15      }
16      public static Test suite() {
17          return new TestSuite(TreeMapTest.class);
# Line 20 | Line 20 | public class TreeMapTest extends JSR166T
20      /**
21       * Create a map from Integers 1-5 to Strings "A"-"E".
22       */
23 <    private static TreeMap map5() {  
23 >    private static TreeMap map5() {
24          TreeMap map = new TreeMap();
25          assertTrue(map.isEmpty());
26          map.put(one, "A");
# Line 43 | Line 43 | public class TreeMapTest extends JSR166T
43      }
44  
45      /**
46 <     *  
46 >     *
47       */
48      public void testConstructFromSorted() {
49          TreeMap map = map5();
# Line 260 | Line 260 | public class TreeMapTest extends JSR166T
260          Iterator it = s.iterator();
261          while (it.hasNext()) {
262              Map.Entry e = (Map.Entry) it.next();
263 <            assertTrue(
263 >            assertTrue(
264                         (e.getKey().equals(one) && e.getValue().equals("A")) ||
265                         (e.getKey().equals(two) && e.getValue().equals("B")) ||
266                         (e.getKey().equals(three) && e.getValue().equals("C")) ||
# Line 279 | Line 279 | public class TreeMapTest extends JSR166T
279          Iterator it = s.iterator();
280          while (it.hasNext()) {
281              Map.Entry e = (Map.Entry) it.next();
282 <            assertTrue(
282 >            assertTrue(
283                         (e.getKey().equals(one) && e.getValue().equals("A")) ||
284                         (e.getKey().equals(two) && e.getValue().equals("B")) ||
285                         (e.getKey().equals(three) && e.getValue().equals("C")) ||
# Line 569 | Line 569 | public class TreeMapTest extends JSR166T
569          for (int i = 1; i <= 5; ++i) {
570              assertTrue(s.indexOf(String.valueOf(i)) >= 0);
571          }
572 <    }        
572 >    }
573  
574      // Exception tests
575  
# Line 581 | Line 581 | public class TreeMapTest extends JSR166T
581              TreeMap c = map5();
582              c.get(null);
583              shouldThrow();
584 <        } catch(NullPointerException e){}
584 >        } catch (NullPointerException e) {}
585      }
586  
587      /**
# Line 592 | Line 592 | public class TreeMapTest extends JSR166T
592              TreeMap c = map5();
593              c.containsKey(null);
594              shouldThrow();
595 <        } catch(NullPointerException e){}
595 >        } catch (NullPointerException e) {}
596      }
597  
598      /**
# Line 604 | Line 604 | public class TreeMapTest extends JSR166T
604              c.put("sadsdf", "asdads");
605              c.remove(null);
606              shouldThrow();
607 <        } catch(NullPointerException e){}
607 >        } catch (NullPointerException e) {}
608      }
609  
610      /**
# Line 625 | Line 625 | public class TreeMapTest extends JSR166T
625              assertEquals(q.size(), r.size());
626              assertTrue(q.equals(r));
627              assertTrue(r.equals(q));
628 <        } catch(Exception e){
628 >        } catch (Exception e) {
629              e.printStackTrace();
630              unexpectedException();
631          }
# Line 658 | Line 658 | public class TreeMapTest extends JSR166T
658          k = (Integer)(r.next());
659          assertEquals(two, k);
660          assertFalse(r.hasNext());
661 <        
661 >
662          Iterator j = sm.keySet().iterator();
663          j.next();
664          j.remove();
# Line 692 | Line 692 | public class TreeMapTest extends JSR166T
692          k = (Integer)(r.next());
693          assertEquals(two, k);
694          assertFalse(r.hasNext());
695 <        
695 >
696          Iterator j = sm.keySet().iterator();
697          j.next();
698          j.remove();
# Line 816 | Line 816 | public class TreeMapTest extends JSR166T
816          NavigableMap<Integer, Integer> result = null;
817          try {
818              result = (NavigableMap<Integer, Integer>) cl.newInstance();
819 <        } catch(Exception e) {
819 >        } catch (Exception e) {
820              fail();
821          }
822          assertEquals(result.size(), 0);
# Line 841 | Line 841 | public class TreeMapTest extends JSR166T
841          }
842  
843          // Remove a bunch of entries with iterator
844 <        for(Iterator<Integer> it = map.keySet().iterator(); it.hasNext(); ) {
844 >        for (Iterator<Integer> it = map.keySet().iterator(); it.hasNext(); ) {
845              if (rnd.nextBoolean()) {
846                  bs.clear(it.next());
847                  it.remove();
# Line 866 | Line 866 | public class TreeMapTest extends JSR166T
866          }
867  
868          // Remove a bunch of entries with iterator
869 <        for(Iterator<Integer> it = map.keySet().iterator(); it.hasNext(); ) {
869 >        for (Iterator<Integer> it = map.keySet().iterator(); it.hasNext(); ) {
870              if (rnd.nextBoolean()) {
871                  bs.clear(it.next());
872                  it.remove();
# Line 882 | Line 882 | public class TreeMapTest extends JSR166T
882                  try {
883                      map.put(key, 2 * key);
884                      fail();
885 <                } catch(IllegalArgumentException e) {
885 >                } catch (IllegalArgumentException e) {
886                      // expected
887                  }
888              }
# Line 1080 | Line 1080 | public class TreeMapTest extends JSR166T
1080              try {
1081                  map.firstKey();
1082                  fail();
1083 <            } catch(NoSuchElementException e) {
1083 >            } catch (NoSuchElementException e) {
1084                  // expected
1085              }
1086              try {
1087                  map.lastKey();
1088                  fail();
1089 <            } catch(NoSuchElementException e) {
1089 >            } catch (NoSuchElementException e) {
1090                  // expected
1091              }
1092          }
# Line 1102 | Line 1102 | public class TreeMapTest extends JSR166T
1102      static boolean eq(Integer i, int j) {
1103          return i == null ? j == -1 : i == j;
1104      }
1105 <    
1105 >
1106   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines