diff --git a/tests/spooled.rs b/tests/spooled.rs index 288d1e6ee..a3bcc03d8 100644 --- a/tests/spooled.rs +++ b/tests/spooled.rs @@ -10,7 +10,7 @@ fn test_automatic_rollover() { let mut buf = Vec::new(); assert!(!t.is_rolled()); - assert_eq!(t.seek(SeekFrom::Current(0)).unwrap(), 0); + assert_eq!(t.stream_position().unwrap(), 0); assert_eq!(t.read_to_end(&mut buf).unwrap(), 0); assert_eq!(buf.as_slice(), b""); buf.clear(); @@ -24,7 +24,7 @@ fn test_automatic_rollover() { assert_eq!(t.write(b"fghijklmno").unwrap(), 10); - assert_eq!(t.seek(SeekFrom::Current(0)).unwrap(), 15); + assert_eq!(t.stream_position().unwrap(), 15); assert!(t.is_rolled()); } @@ -32,13 +32,13 @@ fn test_automatic_rollover() { fn test_explicit_rollover() { let mut t = SpooledTempFile::new(100); assert_eq!(t.write(b"abcdefghijklmnopqrstuvwxyz").unwrap(), 26); - assert_eq!(t.seek(SeekFrom::Current(0)).unwrap(), 26); + assert_eq!(t.stream_position().unwrap(), 26); assert!(!t.is_rolled()); // roll over explicitly assert!(t.roll().is_ok()); assert!(t.is_rolled()); - assert_eq!(t.seek(SeekFrom::Current(0)).unwrap(), 26); + assert_eq!(t.stream_position().unwrap(), 26); let mut buf = Vec::new(); assert_eq!(t.read_to_end(&mut buf).unwrap(), 0); @@ -48,7 +48,7 @@ fn test_explicit_rollover() { assert_eq!(t.seek(SeekFrom::Start(0)).unwrap(), 0); assert_eq!(t.read_to_end(&mut buf).unwrap(), 26); assert_eq!(buf.as_slice(), b"abcdefghijklmnopqrstuvwxyz"); - assert_eq!(t.seek(SeekFrom::Current(0)).unwrap(), 26); + assert_eq!(t.stream_position().unwrap(), 26); } // called by test_seek_{buffer, file} @@ -56,7 +56,7 @@ fn test_explicit_rollover() { fn test_seek(t: &mut SpooledTempFile) { assert_eq!(t.write(b"abcdefghijklmnopqrstuvwxyz").unwrap(), 26); - assert_eq!(t.seek(SeekFrom::Current(0)).unwrap(), 26); // tell() + assert_eq!(t.stream_position().unwrap(), 26); // tell() assert_eq!(t.seek(SeekFrom::Current(-1)).unwrap(), 25); assert_eq!(t.seek(SeekFrom::Current(1)).unwrap(), 26); assert_eq!(t.seek(SeekFrom::Current(1)).unwrap(), 27); @@ -110,7 +110,7 @@ fn test_seek_read(t: &mut SpooledTempFile) { buf.clear(); // now we're at the end again - assert_eq!(t.seek(SeekFrom::Current(0)).unwrap(), 26); // tell() + assert_eq!(t.stream_position().unwrap(), 26); // tell() assert_eq!(t.read_to_end(&mut buf).unwrap(), 0); assert_eq!(buf.as_slice(), b""); buf.clear(); @@ -122,7 +122,7 @@ fn test_seek_read(t: &mut SpooledTempFile) { assert_eq!(buf, *b"fghij"); // read again from current spot - assert_eq!(t.seek(SeekFrom::Current(0)).unwrap(), 10); // tell() + assert_eq!(t.stream_position().unwrap(), 10); // tell() assert!(t.read_exact(&mut buf).is_ok()); assert_eq!(buf, *b"klmno"); @@ -190,11 +190,11 @@ fn test_overwrite_and_extend_rollover() { assert_eq!(t.write(b"abcdefghijklmno").unwrap(), 15); assert!(!t.is_rolled()); assert_eq!(t.seek(SeekFrom::End(-5)).unwrap(), 10); - assert_eq!(t.seek(SeekFrom::Current(0)).unwrap(), 10); // tell() + assert_eq!(t.stream_position().unwrap(), 10); // tell() assert!(!t.is_rolled()); assert_eq!(t.write(b"0123456789)!@#$%^&*(").unwrap(), 20); assert!(t.is_rolled()); - assert_eq!(t.seek(SeekFrom::Current(0)).unwrap(), 30); // tell() + assert_eq!(t.stream_position().unwrap(), 30); // tell() let mut buf = Vec::new(); assert_eq!(t.seek(SeekFrom::Start(0)).unwrap(), 0); assert_eq!(t.read_to_end(&mut buf).unwrap(), 30); @@ -247,11 +247,11 @@ fn test_set_len(t: &mut SpooledTempFile) { assert!(t.set_len(10).is_ok()); // position should not have moved - assert_eq!(t.seek(SeekFrom::Current(0)).unwrap(), 26); // tell() + assert_eq!(t.stream_position().unwrap(), 26); // tell() assert_eq!(t.read_to_end(&mut buf).unwrap(), 0); assert_eq!(buf.as_slice(), b""); - assert_eq!(t.seek(SeekFrom::Current(0)).unwrap(), 26); // tell() + assert_eq!(t.stream_position().unwrap(), 26); // tell() buf.clear(); // read whole thing @@ -262,7 +262,7 @@ fn test_set_len(t: &mut SpooledTempFile) { // set_len to expand beyond the end assert!(t.set_len(40).is_ok()); - assert_eq!(t.seek(SeekFrom::Current(0)).unwrap(), 10); // tell() + assert_eq!(t.stream_position().unwrap(), 10); // tell() assert_eq!(t.seek(SeekFrom::Start(0)).unwrap(), 0); assert_eq!(t.read_to_end(&mut buf).unwrap(), 40); assert_eq!( @@ -290,17 +290,17 @@ fn test_set_len_rollover() { let mut t = spooled_tempfile(10); assert_eq!(t.write(b"abcde").unwrap(), 5); assert!(!t.is_rolled()); - assert_eq!(t.seek(SeekFrom::Current(0)).unwrap(), 5); // tell() + assert_eq!(t.stream_position().unwrap(), 5); // tell() assert_eq!(t.seek(SeekFrom::Start(0)).unwrap(), 0); assert_eq!(t.read_to_end(&mut buf).unwrap(), 5); assert_eq!(buf.as_slice(), b"abcde"); - assert_eq!(t.seek(SeekFrom::Current(0)).unwrap(), 5); // tell() + assert_eq!(t.stream_position().unwrap(), 5); // tell() buf.clear(); assert!(t.set_len(20).is_ok()); assert!(t.is_rolled()); - assert_eq!(t.seek(SeekFrom::Current(0)).unwrap(), 5); // tell() + assert_eq!(t.stream_position().unwrap(), 5); // tell() assert_eq!(t.seek(SeekFrom::Start(0)).unwrap(), 0); assert_eq!(t.read_to_end(&mut buf).unwrap(), 20); assert_eq!(buf.as_slice(), b"abcde\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"); diff --git a/tests/tempdir.rs b/tests/tempdir.rs index de9723328..ce40f9d69 100644 --- a/tests/tempdir.rs +++ b/tests/tempdir.rs @@ -43,7 +43,7 @@ impl PathExt for Path { fn test_tempdir() { let path = { - let p = t!(Builder::new().prefix("foobar").tempdir_in(&Path::new("."))); + let p = t!(Builder::new().prefix("foobar").tempdir_in(Path::new("."))); let p = p.path(); assert!(p.to_str().unwrap().contains("foobar")); p.to_path_buf() @@ -159,17 +159,17 @@ fn recursive_mkdir_rel() { cwd.display(), path.exists() ); - t!(fs::create_dir(&path)); + t!(fs::create_dir(path)); assert!(path.is_dir()); - t!(fs::create_dir_all(&path)); + t!(fs::create_dir_all(path)); assert!(path.is_dir()); } fn recursive_mkdir_dot() { let dot = Path::new("."); - t!(fs::create_dir_all(&dot)); + t!(fs::create_dir_all(dot)); let dotdot = Path::new(".."); - t!(fs::create_dir_all(&dotdot)); + t!(fs::create_dir_all(dotdot)); } fn recursive_mkdir_rel_2() { @@ -181,7 +181,7 @@ fn recursive_mkdir_rel_2() { cwd.display(), path.exists() ); - t!(fs::create_dir_all(&path)); + t!(fs::create_dir_all(path)); assert!(path.is_dir()); assert!(path.parent().unwrap().is_dir()); let path2 = Path::new("quux/blat"); @@ -191,7 +191,7 @@ fn recursive_mkdir_rel_2() { cwd.display() ); t!(fs::create_dir("quux")); - t!(fs::create_dir_all(&path2)); + t!(fs::create_dir_all(path2)); assert!(path2.is_dir()); assert!(path2.parent().unwrap().is_dir()); } @@ -204,9 +204,9 @@ pub fn test_remove_dir_all_ok() { println!("making {}", root.display()); t!(fs::create_dir(&root)); - t!(fs::create_dir(&root.join("foo"))); - t!(fs::create_dir(&root.join("foo").join("bar"))); - t!(fs::create_dir(&root.join("foo").join("bar").join("blat"))); + t!(fs::create_dir(root.join("foo"))); + t!(fs::create_dir(root.join("foo").join("bar"))); + t!(fs::create_dir(root.join("foo").join("bar").join("blat"))); t!(fs::remove_dir_all(&root)); assert!(!root.exists()); assert!(!root.join("bar").exists());