Skip to content

Commit e8fa251

Browse files
authored
Fix tests for no_std build (#384)
This fixes `cargo test --no-default-features`.
1 parent fa464ca commit e8fa251

4 files changed

Lines changed: 11 additions & 3 deletions

File tree

‎tests/test_buf.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![deny(warnings, rust_2018_idioms)]
22

33
use bytes::Buf;
4+
#[cfg(feature = "std")]
45
use std::io::IoSlice;
56

67
#[test]
@@ -42,6 +43,7 @@ fn test_get_u16_buffer_underflow() {
4243
buf.get_u16();
4344
}
4445

46+
#[cfg(feature = "std")]
4547
#[test]
4648
fn test_bufs_vec() {
4749
let buf = &b"hello world"[..];

‎tests/test_buf_mut.rs‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#![deny(warnings, rust_2018_idioms)]
22

3-
use bytes::{buf::IoSliceMut, BufMut, BytesMut};
4-
use std::usize;
5-
use std::fmt::Write;
3+
use bytes::{BufMut, BytesMut};
4+
#[cfg(feature = "std")]
5+
use bytes::buf::IoSliceMut;
6+
use core::usize;
7+
use core::fmt::Write;
68

79
#[test]
810
fn test_vec_as_mut_buf() {
@@ -64,6 +66,7 @@ fn test_clone() {
6466
assert!(buf != buf2);
6567
}
6668

69+
#[cfg(feature = "std")]
6770
#[test]
6871
fn test_bufs_vec_mut() {
6972
let b1: &mut [u8] = &mut [];

‎tests/test_chain.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use bytes::{Buf, BufMut, Bytes};
44
use bytes::buf::{BufExt, BufMutExt};
5+
#[cfg(feature = "std")]
56
use std::io::IoSlice;
67

78
#[test]
@@ -42,6 +43,7 @@ fn iterating_two_bufs() {
4243
assert_eq!(res, &b"helloworld"[..]);
4344
}
4445

46+
#[cfg(feature = "std")]
4547
#[test]
4648
fn vectored_read() {
4749
let a = Bytes::from(&b"hello"[..]);

‎tests/test_reader.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![deny(warnings, rust_2018_idioms)]
2+
#![cfg(feature = "std")]
23

34
use std::io::{BufRead, Read};
45

0 commit comments

Comments
 (0)