ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/jtreg/util/Hashtable/IllegalLoadFactor.java
(Generate patch)

Comparing jsr166/src/test/jtreg/util/Hashtable/IllegalLoadFactor.java (file contents):
Revision 1.5 by jsr166, Sun Oct 11 00:58:42 2015 UTC vs.
Revision 1.6 by jsr166, Sat Oct 21 00:39:10 2017 UTC

# Line 34 | Line 34 | import java.util.*;
34   */
35   public class IllegalLoadFactor {
36  
37 <      public static void main(String argv[]) throws Exception {
38 <          boolean testSucceeded = false;
39 <          try {
40 <              // this should generate an IllegalArgumentException
41 <              Hashtable bad1 = new Hashtable(100, -3);
42 <          }
43 <          catch (IllegalArgumentException e1) {
44 <              testSucceeded = true;
45 <          }
46 <          if (!testSucceeded)
47 <              throw new Exception("Hashtable, negative load factor");
48 <
49 <          testSucceeded = false;
50 <          try {
51 <              // this should generate an IllegalArgumentException
52 <              Hashtable bad1 = new Hashtable(100, Float.NaN);
53 <          }
54 <          catch (IllegalArgumentException e1) {
55 <              testSucceeded = true;
56 <          }
57 <          if (!testSucceeded)
58 <              throw new Exception("Hashtable, NaN load factor");
59 <
60 <          testSucceeded = false;
61 <          try {
62 <              // this should generate an IllegalArgumentException
63 <              HashMap bad1 = new HashMap(100, -3);
64 <          }
65 <          catch (IllegalArgumentException e1) {
66 <              testSucceeded = true;
67 <          }
68 <          if (!testSucceeded)
69 <              throw new Exception("HashMap, negative load factor");
70 <
71 <          testSucceeded = false;
72 <          try {
73 <              // this should generate an IllegalArgumentException
74 <              HashMap bad1 = new HashMap(100, Float.NaN);
75 <          }
76 <          catch (IllegalArgumentException e1) {
77 <              testSucceeded = true;
78 <          }
79 <          if (!testSucceeded)
80 <              throw new Exception("HashMap, NaN load factor");
81 <
82 <
83 <          testSucceeded = false;
84 <          try {
85 <              // this should generate an IllegalArgumentException
86 <              HashSet bad1 = new HashSet(100, -3);
87 <          }
88 <          catch (IllegalArgumentException e1) {
89 <              testSucceeded = true;
90 <          }
91 <          if (!testSucceeded)
92 <              throw new Exception("HashSet, negative load factor");
93 <
94 <          testSucceeded = false;
95 <          try {
96 <              // this should generate an IllegalArgumentException
97 <              HashSet bad1 = new HashSet(100, Float.NaN);
98 <          }
99 <          catch (IllegalArgumentException e1) {
100 <              testSucceeded = true;
101 <          }
102 <          if (!testSucceeded)
103 <              throw new Exception("HashSet, NaN load factor");
104 <
105 <          testSucceeded = false;
106 <          try {
107 <              // this should generate an IllegalArgumentException
108 <              WeakHashMap bad1 = new WeakHashMap(100, -3);
109 <          }
110 <          catch (IllegalArgumentException e1) {
111 <              testSucceeded = true;
112 <          }
113 <          if (!testSucceeded)
114 <              throw new Exception("WeakHashMap, negative load factor");
115 <
116 <          testSucceeded = false;
117 <          try {
118 <              // this should generate an IllegalArgumentException
119 <              WeakHashMap bad1 = new WeakHashMap(100, Float.NaN);
120 <          }
121 <          catch (IllegalArgumentException e1) {
122 <              testSucceeded = true;
123 <          }
124 <          if (!testSucceeded)
125 <              throw new Exception("WeakHashMap, NaN load factor");
126 <
127 <          // Make sure that legal creates don't throw exceptions
128 <          Map goodMap = new Hashtable(100, .69f);
129 <          goodMap = new HashMap(100, .69f);
130 <          Set goodSet = new HashSet(100, .69f);
131 <          goodMap = new WeakHashMap(100, .69f);
132 <     }
133 <
37 >    public static void main(String argv[]) throws Exception {
38 >        boolean testSucceeded = false;
39 >        try {
40 >            // this should generate an IllegalArgumentException
41 >            Hashtable bad1 = new Hashtable(100, -3);
42 >        }
43 >        catch (IllegalArgumentException e1) {
44 >            testSucceeded = true;
45 >        }
46 >        if (!testSucceeded)
47 >            throw new Exception("Hashtable, negative load factor");
48 >
49 >        testSucceeded = false;
50 >        try {
51 >            // this should generate an IllegalArgumentException
52 >            Hashtable bad1 = new Hashtable(100, Float.NaN);
53 >        }
54 >        catch (IllegalArgumentException e1) {
55 >            testSucceeded = true;
56 >        }
57 >        if (!testSucceeded)
58 >            throw new Exception("Hashtable, NaN load factor");
59 >
60 >        testSucceeded = false;
61 >        try {
62 >            // this should generate an IllegalArgumentException
63 >            HashMap bad1 = new HashMap(100, -3);
64 >        }
65 >        catch (IllegalArgumentException e1) {
66 >            testSucceeded = true;
67 >        }
68 >        if (!testSucceeded)
69 >            throw new Exception("HashMap, negative load factor");
70 >
71 >        testSucceeded = false;
72 >        try {
73 >            // this should generate an IllegalArgumentException
74 >            HashMap bad1 = new HashMap(100, Float.NaN);
75 >        }
76 >        catch (IllegalArgumentException e1) {
77 >            testSucceeded = true;
78 >        }
79 >        if (!testSucceeded)
80 >            throw new Exception("HashMap, NaN load factor");
81 >
82 >
83 >        testSucceeded = false;
84 >        try {
85 >            // this should generate an IllegalArgumentException
86 >            HashSet bad1 = new HashSet(100, -3);
87 >        }
88 >        catch (IllegalArgumentException e1) {
89 >            testSucceeded = true;
90 >        }
91 >        if (!testSucceeded)
92 >            throw new Exception("HashSet, negative load factor");
93 >
94 >        testSucceeded = false;
95 >        try {
96 >            // this should generate an IllegalArgumentException
97 >            HashSet bad1 = new HashSet(100, Float.NaN);
98 >        }
99 >        catch (IllegalArgumentException e1) {
100 >            testSucceeded = true;
101 >        }
102 >        if (!testSucceeded)
103 >            throw new Exception("HashSet, NaN load factor");
104 >
105 >        testSucceeded = false;
106 >        try {
107 >            // this should generate an IllegalArgumentException
108 >            WeakHashMap bad1 = new WeakHashMap(100, -3);
109 >        }
110 >        catch (IllegalArgumentException e1) {
111 >            testSucceeded = true;
112 >        }
113 >        if (!testSucceeded)
114 >            throw new Exception("WeakHashMap, negative load factor");
115 >
116 >        testSucceeded = false;
117 >        try {
118 >            // this should generate an IllegalArgumentException
119 >            WeakHashMap bad1 = new WeakHashMap(100, Float.NaN);
120 >        }
121 >        catch (IllegalArgumentException e1) {
122 >            testSucceeded = true;
123 >        }
124 >        if (!testSucceeded)
125 >            throw new Exception("WeakHashMap, NaN load factor");
126 >
127 >        // Make sure that legal creates don't throw exceptions
128 >        Map goodMap = new Hashtable(100, .69f);
129 >        goodMap = new HashMap(100, .69f);
130 >        Set goodSet = new HashSet(100, .69f);
131 >        goodMap = new WeakHashMap(100, .69f);
132 >    }
133   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines