import java.util.Random; class GenerateTestData { public static void main(String[] args) { System.out.println("// Rust file generated by Java"); // nextBytes test { Random rand = new Random(0); System.out.println("pub const RAND_NEXTBYTES_SEED: u64 = 0;"); System.out.print("pub const RAND_NEXTBYTES: [u8; 128] = ["); byte[] bytes = new byte[128]; rand.nextBytes(bytes); for(int i = 0; i < 128; i++) { if(i % 8 == 0) { System.out.print("\n\t"); } System.out.printf("0x%02X, ", bytes[i]); } System.out.println("\n];"); } // nextInt test { Random rand = new Random(123); System.out.println("pub const RAND_NEXT32_SEED: u64 = 123;"); System.out.print("pub const RAND_NEXT32: [u32; 128] = ["); for(int i = 0; i < 128; i++) { if(i % 8 == 0) { System.out.print("\n\t"); } System.out.printf("0x%08X, ", rand.nextInt()); } System.out.println("\n];"); } System.out.println(); // nextLong test { Random rand = new Random(246); System.out.println("pub const RAND_NEXT64_SEED: u64 = 246;"); System.out.print("pub const RAND_NEXT64: [u64; 128] = ["); for(int i = 0; i < 128; i++) { if(i % 8 == 0) { System.out.print("\n\t"); } System.out.printf("0x%016X, ", rand.nextLong()); } System.out.println("\n];"); } // nextIntBound65536 test { Random rand = new Random(369); System.out.println("pub const RAND_NEXT32_BOUND_65536_SEED: u64 = 369;"); System.out.print("pub const RAND_NEXT32_BOUND_65536: [u32; 128] = ["); for(int i = 0; i < 128; i++) { if(i % 8 == 0) { System.out.print("\n\t"); } System.out.printf("0x%08X, ", rand.nextInt(65536)); } System.out.println("\n];"); } // nextIntBound999999999 test { Random rand = new Random(369); System.out.println("pub const RAND_NEXT32_BOUND_999999999_SEED: u64 = 369;"); System.out.print("pub const RAND_NEXT32_BOUND_999999999: [u32; 128] = ["); for(int i = 0; i < 128; i++) { if(i % 8 == 0) { System.out.print("\n\t"); } System.out.printf("0x%08X, ", rand.nextInt(999999999)); } System.out.println("\n];"); } System.out.println(); // nextBool test { Random rand = new Random(492); System.out.println("pub const RAND_NEXTBOOL_SEED: u64 = 492;"); System.out.print("pub const RAND_NEXTBOOL: [bool; 128] = ["); for(int i = 0; i < 128; i++) { if(i % 8 == 0) { System.out.print("\n\t"); } System.out.printf("%s, ", rand.nextBoolean()); } System.out.println("\n];"); } System.out.println(); // nextFloat test { Random rand = new Random(615); System.out.println("pub const RAND_NEXTF32_SEED: u64 = 615;"); System.out.println("// f32 bit representation"); System.out.print("pub const RAND_NEXTF32: [u32; 128] = ["); for(int i = 0; i < 128; i++) { if(i % 8 == 0) { System.out.print("\n\t"); } System.out.printf("0x%08X, ", Float.floatToIntBits(rand.nextFloat())); } System.out.println("\n];"); } System.out.println(); // nextDouble test { Random rand = new Random(738); System.out.println("pub const RAND_NEXTF64_SEED: u64 = 738;"); System.out.println("// f64 bit representation"); System.out.print("pub const RAND_NEXTF64: [u64; 128] = ["); for(int i = 0; i < 128; i++) { if(i % 8 == 0) { System.out.print("\n\t"); } System.out.printf("0x%016X, ", Double.doubleToLongBits(rand.nextDouble())); } System.out.println("\n];"); } System.out.println(); // nextGaussian test { Random rand = new Random(861); System.out.println("pub const RAND_NEXTGAUSSIAN_SEED: u64 = 861;"); System.out.println("// f64 bit representation"); System.out.print("pub const RAND_NEXTGAUSSIAN: [u64; 128] = ["); for(int i = 0; i < 128; i++) { if(i % 8 == 0) { System.out.print("\n\t"); } System.out.printf("0x%016X, ", Double.doubleToLongBits(rand.nextGaussian())); } System.out.println("\n];"); } } }