Skip to content

Commit dfc0d1c

Browse files
committed
Revert testing changes
Signed-off-by: Joe Richey <[email protected]>
1 parent 2bb9a7d commit dfc0d1c

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

tests/common/mod.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use super::getrandom_impl;
2-
use core::mem::{self, MaybeUninit};
32

43
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
54
use wasm_bindgen_test::wasm_bindgen_test as test;
@@ -10,16 +9,16 @@ wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
109
#[test]
1110
fn test_zero() {
1211
// Test that APIs are happy with zero-length requests
13-
getrandom_impl(unsafe { slice_as_uninit_mut(&mut [0u8; 0]) }).unwrap();
12+
getrandom_impl(&mut [0u8; 0]).unwrap();
1413
}
1514

1615
#[test]
1716
fn test_diff() {
1817
let mut v1 = [0u8; 1000];
19-
getrandom_impl(unsafe { slice_as_uninit_mut(&mut v1) }).unwrap();
18+
getrandom_impl(&mut v1).unwrap();
2019

2120
let mut v2 = [0u8; 1000];
22-
getrandom_impl(unsafe { slice_as_uninit_mut(&mut v2) }).unwrap();
21+
getrandom_impl(&mut v2).unwrap();
2322

2423
let mut n_diff_bits = 0;
2524
for i in 0..v1.len() {
@@ -33,7 +32,7 @@ fn test_diff() {
3332
#[test]
3433
fn test_huge() {
3534
let mut huge = [0u8; 100_000];
36-
getrandom_impl(unsafe { slice_as_uninit_mut(&mut huge) }).unwrap();
35+
getrandom_impl(&mut huge).unwrap();
3736
}
3837

3938
// On WASM, the thread API always fails/panics
@@ -52,9 +51,9 @@ fn test_multithreading() {
5251
// wait until all the tasks are ready to go.
5352
rx.recv().unwrap();
5453
let mut v = [0u8; 1000];
55-
let y = unsafe { slice_as_uninit_mut(&mut v) };
54+
5655
for _ in 0..100 {
57-
getrandom_impl(y).unwrap();
56+
getrandom_impl(&mut v).unwrap();
5857
thread::yield_now();
5958
}
6059
});
@@ -65,9 +64,3 @@ fn test_multithreading() {
6564
tx.send(()).unwrap();
6665
}
6766
}
68-
69-
#[inline(always)]
70-
unsafe fn slice_as_uninit_mut<T>(slice: &mut [T]) -> &mut [MaybeUninit<T>] {
71-
// SAFETY: `MaybeUninit<T>` is guaranteed to be layout-compatible with `T`.
72-
mem::transmute(slice)
73-
}

tests/normal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
)))]
88

99
// Use the normal getrandom implementation on this architecture.
10-
use getrandom::getrandom_uninit as getrandom_impl;
10+
use getrandom::getrandom as getrandom_impl;
1111
mod common;

0 commit comments

Comments
 (0)