jdk/test/java/lang/Integer/BitTwiddle.java
changeset 30048 3424bede284d
parent 30046 cf2c86e1819e
child 30436 17827057ef5a
equal deleted inserted replaced
30047:63b6a16968d5 30048:3424bede284d
     1 /*
     1 /*
     2  * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
    24 /*
    24 /*
    25  * @test
    25  * @test
    26  * @bug     4495754
    26  * @library /lib/testlibrary/
    27  * @summary Basic test for int bit twiddling
    27  * @build jdk.testlibrary.*
       
    28  * @run main BitTwiddle
       
    29  * @bug     4495754 8078672
       
    30  * @summary Basic test for int bit twiddling (use -Dseed=X to set PRNG seed)
    28  * @author  Josh Bloch
    31  * @author  Josh Bloch
    29  * @key randomness
    32  * @key randomness
    30  */
    33  */
    31 
    34 
    32 import java.util.Random;
    35 import java.util.Random;
    34 
    37 
    35 public class BitTwiddle {
    38 public class BitTwiddle {
    36     private static final int N = 1000; // # of repetitions per test
    39     private static final int N = 1000; // # of repetitions per test
    37 
    40 
    38     public static void main(String args[]) {
    41     public static void main(String args[]) {
    39         Random rnd = new Random();
    42         Random rnd = RandomFactory.getRandom();
    40 
    43 
    41         if (highestOneBit(0) != 0)
    44         if (highestOneBit(0) != 0)
    42             throw new RuntimeException("a");
    45             throw new RuntimeException("a");
    43         if (highestOneBit(-1) != MIN_VALUE)
    46         if (highestOneBit(-1) != MIN_VALUE)
    44             throw new RuntimeException("b");
    47             throw new RuntimeException("b");