Skip to content

Commit 1f680b6

Browse files
committed
fix: cfg-ing out tests that require test alloc guarded features
1 parent 63afa4b commit 1f680b6

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#![deny(rust_2018_idioms)]
2424
#![deny(unused)]
2525

26-
#[cfg(any(feature = "alloc", test))]
26+
#[cfg(feature = "alloc")]
2727
extern crate alloc;
2828

2929
mod error;
@@ -80,7 +80,7 @@ impl core::error::Error for MaxRecursionReached {}
8080
/// ```
8181
/// # #[cfg(feature = "derive")] mod foo {
8282
/// use arbitrary::Arbitrary;
83-
/// use alloc::collections::HashSet;
83+
/// use std::collections::HashSet;
8484
///
8585
/// #[derive(Arbitrary)]
8686
/// pub struct AddressBook {

src/tests.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
#[cfg(feature = "alloc")]
2+
use alloc::{rc::Rc, string::String, sync::Arc, vec::Vec};
13
use {
24
super::{Arbitrary, Result, Unstructured},
3-
alloc::{rc::Rc, sync::Arc},
45
core::{fmt::Debug, hash::Hash},
56
std::collections::HashSet,
67
};
@@ -156,6 +157,7 @@ fn arbitrary_take_rest_for_bytes() {
156157
}
157158

158159
#[test]
160+
#[cfg(feature = "alloc")]
159161
fn arbitrary_for_vec_u8() {
160162
assert_generates::<Vec<u8>>([
161163
vec![],
@@ -177,6 +179,7 @@ fn arbitrary_for_vec_u8() {
177179
}
178180

179181
#[test]
182+
#[cfg(feature = "alloc")]
180183
fn arbitrary_for_vec_vec_u8() {
181184
assert_generates::<Vec<Vec<u8>>>([
182185
vec![],
@@ -195,6 +198,7 @@ fn arbitrary_for_vec_vec_u8() {
195198
}
196199

197200
#[test]
201+
#[cfg(feature = "alloc")]
198202
fn arbitrary_for_vec_vec_vec_u8() {
199203
assert_generates::<Vec<Vec<Vec<u8>>>>([
200204
vec![],
@@ -219,11 +223,13 @@ fn arbitrary_for_vec_vec_vec_u8() {
219223
}
220224

221225
#[test]
226+
#[cfg(feature = "alloc")]
222227
fn arbitrary_for_string() {
223228
assert_generates::<String>(["".into(), "a".into(), "aa".into(), "aaa".into()]);
224229
}
225230

226231
#[test]
232+
#[cfg(feature = "alloc")]
227233
fn arbitrary_collection() {
228234
let x = [
229235
1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 12,
@@ -259,6 +265,7 @@ fn arbitrary_collection() {
259265
}
260266

261267
#[test]
268+
#[cfg(feature = "alloc")]
262269
fn arbitrary_take_rest() {
263270
// Basic examples
264271
let x = [1, 2, 3, 4];
@@ -309,6 +316,7 @@ fn arbitrary_take_rest() {
309316
}
310317

311318
#[test]
319+
#[cfg(feature = "alloc")]
312320
fn size_hint_for_tuples() {
313321
assert_eq!(
314322
(7, Some(7)),

0 commit comments

Comments
 (0)