]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_data_structures/small_c_str.rs
Auto merge of #65202 - pietroalbini:scriptify-ci-config, r=alexcrichton
[rust.git] / src / librustc_data_structures / small_c_str.rs
index 08794fbec8dc5df7adb7ae66083e137e94b85b64..9d90b9052d1c200f9724c1e8ddb1c6bd01072a2b 100644 (file)
@@ -1,18 +1,11 @@
-// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
 use std::ffi;
 use std::ops::Deref;
 
 use smallvec::SmallVec;
 
+#[cfg(test)]
+mod tests;
+
 const SIZE: usize = 36;
 
 /// Like SmallVec but for C strings.
@@ -76,47 +69,3 @@ fn deref(&self) -> &ffi::CStr {
         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");
-}