| ... | @@ -153,8 +153,14 @@ pub fn getRandomBytes(buf: []u8) !void { | ... | @@ -153,8 +153,14 @@ pub fn getRandomBytes(buf: []u8) !void { |
| 153 | } | 153 | } |
| 154 | | 154 | |
| 155 | test "os.getRandomBytes" { | 155 | test "os.getRandomBytes" { |
| 156 | var buf: [50]u8 = undefined; | 156 | var buf_a: [50]u8 = undefined; |
| 157 | try getRandomBytes(buf[0..]); | 157 | var buf_b: [50]u8 = undefined; |
| | 158 | // Call Twice |
| | 159 | try getRandomBytes(buf_a[0..]); |
| | 160 | try getRandomBytes(buf_b[0..]); |
| | 161 | |
| | 162 | // Check if random (not 100% conclusive) |
| | 163 | assert( !mem.eql(u8, buf_a, buf_b) ); |
| 158 | } | 164 | } |
| 159 | | 165 | |
| 160 | /// Raises a signal in the current kernel thread, ending its execution. | 166 | /// Raises a signal in the current kernel thread, ending its execution. |