]> 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 bde7911267f7744255e9972a9fc7846830b60f0c..9d90b9052d1c200f9724c1e8ddb1c6bd01072a2b 100644 (file)
@@ -3,6 +3,9 @@
 
 use smallvec::SmallVec;
 
+#[cfg(test)]
+mod tests;
+
 const SIZE: usize = 36;
 
 /// Like SmallVec but for C strings.
@@ -66,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");
-}