Skip to content

Commit

Permalink
Fix tests for no_std build (#384)
Browse files Browse the repository at this point in the history
This fixes `cargo test --no-default-features`.
  • Loading branch information
xu-cheng authored May 22, 2020
1 parent fa464ca commit e8fa251
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions tests/test_buf.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![deny(warnings, rust_2018_idioms)]

use bytes::Buf;
#[cfg(feature = "std")]
use std::io::IoSlice;

#[test]
Expand Down Expand Up @@ -42,6 +43,7 @@ fn test_get_u16_buffer_underflow() {
buf.get_u16();
}

#[cfg(feature = "std")]
#[test]
fn test_bufs_vec() {
let buf = &b"hello world"[..];
Expand Down
9 changes: 6 additions & 3 deletions tests/test_buf_mut.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#![deny(warnings, rust_2018_idioms)]

use bytes::{buf::IoSliceMut, BufMut, BytesMut};
use std::usize;
use std::fmt::Write;
use bytes::{BufMut, BytesMut};
#[cfg(feature = "std")]
use bytes::buf::IoSliceMut;
use core::usize;
use core::fmt::Write;

#[test]
fn test_vec_as_mut_buf() {
Expand Down Expand Up @@ -64,6 +66,7 @@ fn test_clone() {
assert!(buf != buf2);
}

#[cfg(feature = "std")]
#[test]
fn test_bufs_vec_mut() {
let b1: &mut [u8] = &mut [];
Expand Down
2 changes: 2 additions & 0 deletions tests/test_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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

#[test]
Expand Down Expand Up @@ -42,6 +43,7 @@ fn iterating_two_bufs() {
assert_eq!(res, &b"helloworld"[..]);
}

#[cfg(feature = "std")]
#[test]
fn vectored_read() {
let a = Bytes::from(&b"hello"[..]);
Expand Down
1 change: 1 addition & 0 deletions tests/test_reader.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![deny(warnings, rust_2018_idioms)]
#![cfg(feature = "std")]

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

Expand Down

0 comments on commit e8fa251

Please sign in to comment.