diff options
| author | kristopher tate <kt@connectfree.co.jp> | 2018-08-03 02:16:19 +0900 |
|---|---|---|
| committer | kristopher tate <kt@connectfree.co.jp> | 2018-08-03 02:16:19 +0900 |
| commit | dde7eb45c51dd96242a6b028eb1912ee6ffa2c55 (patch) | |
| tree | 41b9983039e34c0d5c230f228b27eee6e2c477ff | |
| parent | c44653f40f37c93fc68a2e455d693bb11f1c11d3 (diff) | |
| download | zig-dde7eb45c51dd96242a6b028eb1912ee6ffa2c55.tar.gz zig-dde7eb45c51dd96242a6b028eb1912ee6ffa2c55.zip | |
std/os/index.zig: call getRandomBytes() twice and compare;
Tracking Issue #1318 ;
| -rw-r--r-- | std/os/index.zig | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/std/os/index.zig b/std/os/index.zig index 7042247a2f..87edce3dac 100644 --- a/std/os/index.zig +++ b/std/os/index.zig @@ -153,8 +153,14 @@ pub fn getRandomBytes(buf: []u8) !void { } test "os.getRandomBytes" { - var buf: [50]u8 = undefined; - try getRandomBytes(buf[0..]); + var buf_a: [50]u8 = undefined; + var buf_b: [50]u8 = undefined; + // Call Twice + try getRandomBytes(buf_a[0..]); + try getRandomBytes(buf_b[0..]); + + // Check if random (not 100% conclusive) + assert( !mem.eql(u8, buf_a, buf_b) ); } /// Raises a signal in the current kernel thread, ending its execution. |
