Преглед на файлове

Use url.path_mut() in tests.

Simon Sapin преди 12 години
родител
ревизия
678bb4d526
променени са 1 файла, в които са добавени 6 реда и са изтрити 14 реда
  1. 6 14
      src/tests.rs

+ 6 - 14
src/tests.rs

@@ -197,14 +197,6 @@ fn unescape(input: &str) -> String {
 }
 
 
-fn set_path(url: &mut Url, path: Vec<String>) {
-    match url.scheme_data {
-        RelativeSchemeData(ref mut scheme_data) => scheme_data.path = path,
-        _ => fail!()
-    }
-}
-
-
 #[test]
 fn file_paths() {
     assert_eq!(Url::from_file_path(&path::posix::Path::new("relative")), Err(()));
@@ -219,14 +211,14 @@ fn file_paths() {
     assert_eq!(url.path(), Some(&["foo".to_string(), "bar".to_string()]));
     assert!(url.to_file_path() == Ok(path::posix::Path::new("/foo/bar")));
 
-    set_path(&mut url, vec!["foo".to_string(), "ba\0r".to_string()]);
+    *url.path_mut().unwrap().get_mut(1) = "ba\0r".to_string();
     assert!(url.to_file_path::<path::posix::Path>() == Err(()));
 
-    set_path(&mut url, vec!["foo".to_string(), "ba%00r".to_string()]);
+    *url.path_mut().unwrap().get_mut(1) = "ba%00r".to_string();
     assert!(url.to_file_path::<path::posix::Path>() == Err(()));
 
     // Invalid UTF-8
-    set_path(&mut url, vec!["foo".to_string(), "ba%80r".to_string()]);
+    *url.path_mut().unwrap().get_mut(1) = "ba%80r".to_string();
     assert!(url.to_file_path() == Ok(path::posix::Path::new(
         /* note: byte string, invalid UTF-8 */ b"/foo/ba\x80r")));
 
@@ -236,14 +228,14 @@ fn file_paths() {
     assert!(url.to_file_path::<path::windows::Path>()
             == Ok(path::windows::Path::new(r"C:\foo\bar")));
 
-    set_path(&mut url, vec!["C:".to_string(), "foo".to_string(), "ba\0r".to_string()]);
+    *url.path_mut().unwrap().get_mut(2) = "ba\0r".to_string();
     assert!(url.to_file_path::<path::windows::Path>() == Err(()));
 
-    set_path(&mut url, vec!["C:".to_string(), "foo".to_string(), "ba%00r".to_string()]);
+    *url.path_mut().unwrap().get_mut(2) = "ba%00r".to_string();
     assert!(url.to_file_path::<path::windows::Path>() == Err(()));
 
     // Invalid UTF-8
-    set_path(&mut url, vec!["C:".to_string(), "foo".to_string(), "ba%80r".to_string()]);
+    *url.path_mut().unwrap().get_mut(2) = "ba%80r".to_string();
     assert!(url.to_file_path::<path::windows::Path>() == Err(()));
 }