diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-08-01 23:57:23 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-08-02 01:59:01 +0300 |
| commit | e118eb6c7970385fbcdd688d03975f65d88e642e (patch) | |
| tree | 52f7b93573ee2e7c0963f66f4907fc44e6c15443 /src/librustc_data_structures/small_c_str.rs | |
| parent | ca0ef0fcf66b0fe913c19a3a00729af4494866e6 (diff) | |
| download | rust-e118eb6c7970385fbcdd688d03975f65d88e642e.tar.gz rust-e118eb6c7970385fbcdd688d03975f65d88e642e.zip | |
librustc_data_structures: Unconfigure tests during normal build
Diffstat (limited to 'src/librustc_data_structures/small_c_str.rs')
| -rw-r--r-- | src/librustc_data_structures/small_c_str.rs | 47 |
1 files changed, 3 insertions, 44 deletions
diff --git a/src/librustc_data_structures/small_c_str.rs b/src/librustc_data_structures/small_c_str.rs index bde7911267f..9d90b9052d1 100644 --- a/src/librustc_data_structures/small_c_str.rs +++ b/src/librustc_data_structures/small_c_str.rs @@ -3,6 +3,9 @@ use std::ops::Deref; use smallvec::SmallVec; +#[cfg(test)] +mod tests; + const SIZE: usize = 36; /// Like SmallVec but for C strings. @@ -66,47 +69,3 @@ impl Deref for SmallCStr { self.as_c_str() } } - -#[test] -fn short() { - const TEXT: &str = "abcd"; - let reference = ffi::CString::new(TEXT.to_string()).unwrap(); - - let scs = SmallCStr::new(TEXT); - - assert_eq!(scs.len_with_nul(), TEXT.len() + 1); - assert_eq!(scs.as_c_str(), reference.as_c_str()); - assert!(!scs.spilled()); -} - -#[test] -fn empty() { - const TEXT: &str = ""; - let reference = ffi::CString::new(TEXT.to_string()).unwrap(); - - let scs = SmallCStr::new(TEXT); - - assert_eq!(scs.len_with_nul(), TEXT.len() + 1); - assert_eq!(scs.as_c_str(), reference.as_c_str()); - assert!(!scs.spilled()); -} - -#[test] -fn long() { - const TEXT: &str = "01234567890123456789012345678901234567890123456789\ - 01234567890123456789012345678901234567890123456789\ - 01234567890123456789012345678901234567890123456789"; - let reference = ffi::CString::new(TEXT.to_string()).unwrap(); - - let scs = SmallCStr::new(TEXT); - - assert_eq!(scs.len_with_nul(), TEXT.len() + 1); - assert_eq!(scs.as_c_str(), reference.as_c_str()); - assert!(scs.spilled()); -} - -#[test] -#[should_panic] -fn internal_nul() { - let _ = SmallCStr::new("abcd\0def"); -} |
