8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 6410729 6586631
27 * @summary Test previousClearBit, previousSetBit
28 */
29
30 import java.util.*;
31
32 public class PreviousBits {
33
34 void testHashCode(final BitSet s) {
35 long h = 1234;
36 long[] words = s.toLongArray();
37 for (int i = words.length; --i >= 0; )
38 h ^= words[i] * (i + 1);
39 equal((int)((h >> 32) ^ h), s.hashCode());
40 }
41
42 void testOutOfBounds(final BitSet s) {
43 THROWS(IndexOutOfBoundsException.class,
44 new F(){void f(){ s.previousSetBit(-2);}},
45 new F(){void f(){ s.previousClearBit(-2);}},
46 new F(){void f(){ s.previousSetBit(Integer.MIN_VALUE);}},
47 new F(){void f(){ s.previousClearBit(Integer.MIN_VALUE);}},
|
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 6410729 6586631
27 * @summary Test previousClearBit, previousSetBit
28 * @key randomness
29 */
30
31 import java.util.*;
32
33 public class PreviousBits {
34
35 void testHashCode(final BitSet s) {
36 long h = 1234;
37 long[] words = s.toLongArray();
38 for (int i = words.length; --i >= 0; )
39 h ^= words[i] * (i + 1);
40 equal((int)((h >> 32) ^ h), s.hashCode());
41 }
42
43 void testOutOfBounds(final BitSet s) {
44 THROWS(IndexOutOfBoundsException.class,
45 new F(){void f(){ s.previousSetBit(-2);}},
46 new F(){void f(){ s.previousClearBit(-2);}},
47 new F(){void f(){ s.previousSetBit(Integer.MIN_VALUE);}},
48 new F(){void f(){ s.previousClearBit(Integer.MIN_VALUE);}},
|