1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
--- a/tests/smoke.rs
+++ b/tests/smoke.rs
@@ -7,2 +7,3 @@
#[test]
+#[cfg(feature = "std")]
fn bool() {
@@ -14,2 +15,3 @@
#[test]
+#[cfg(feature = "std")]
fn u8() {
@@ -25,2 +27,3 @@
#[test]
+#[cfg(feature = "std")]
fn i8() {
@@ -36,2 +39,3 @@
#[test]
+#[cfg(feature = "std")]
fn u32() {
@@ -49,2 +53,3 @@
#[test]
+#[cfg(feature = "std")]
fn u64() {
@@ -63,2 +68,3 @@
#[test]
+#[cfg(feature = "std")]
fn u128() {
@@ -77,5 +83,12 @@
+fn getrng() -> fastrand::Rng {
+ #[cfg(feature="std")]
+ return fastrand::Rng::new();
+ #[cfg(not(feature="std"))]
+ return fastrand::Rng::with_seed(0xDEADBEEFBAADF00D);
+}
+
#[test]
fn fill() {
- let mut r = fastrand::Rng::new();
+ let mut r = getrng();
let mut a = [0u8; 64];
@@ -91,3 +104,3 @@
fn rng() {
- let mut r = fastrand::Rng::new();
+ let mut r = getrng();
@@ -103,2 +116,3 @@
#[test]
+#[cfg(feature="std")]
fn rng_init() {
@@ -116,3 +130,3 @@
let mut a = fastrand::Rng::with_seed(7);
- let mut b = fastrand::Rng::new();
+ let mut b = getrng();
b.seed(7);
@@ -122,4 +136,5 @@
#[test]
+#[cfg(feature = "alloc")]
fn choose_multiple() {
- let mut a = fastrand::Rng::new();
+ let mut a = getrng();
let mut elements = (0..20).collect::<Vec<_>>();
@@ -137,3 +152,3 @@
let items = [1, 4, 9, 5, 2, 3, 6, 7, 8, 0];
- let mut r = fastrand::Rng::new();
+ let mut r = getrng();
|