summaryrefslogtreecommitdiffstats
path: root/library/std/src/fs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
commit1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch)
tree3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /library/std/src/fs
parentReleasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz
rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/std/src/fs')
-rw-r--r--library/std/src/fs/tests.rs20
1 files changed, 19 insertions, 1 deletions
diff --git a/library/std/src/fs/tests.rs b/library/std/src/fs/tests.rs
index 909d9bf40..401def184 100644
--- a/library/std/src/fs/tests.rs
+++ b/library/std/src/fs/tests.rs
@@ -2,7 +2,8 @@ use crate::io::prelude::*;
use crate::env;
use crate::fs::{self, File, OpenOptions};
-use crate::io::{ErrorKind, SeekFrom};
+use crate::io::{BorrowedBuf, ErrorKind, SeekFrom};
+use crate::mem::MaybeUninit;
use crate::path::Path;
use crate::str;
use crate::sync::Arc;
@@ -402,6 +403,23 @@ fn file_test_io_seek_read_write() {
}
#[test]
+fn file_test_read_buf() {
+ let tmpdir = tmpdir();
+ let filename = &tmpdir.join("test");
+ check!(fs::write(filename, &[1, 2, 3, 4]));
+
+ let mut buf: [MaybeUninit<u8>; 128] = MaybeUninit::uninit_array();
+ let mut buf = BorrowedBuf::from(buf.as_mut_slice());
+ let mut file = check!(File::open(filename));
+ check!(file.read_buf(buf.unfilled()));
+ assert_eq!(buf.filled(), &[1, 2, 3, 4]);
+ // File::read_buf should omit buffer initialization.
+ assert_eq!(buf.init_len(), 4);
+
+ check!(fs::remove_file(filename));
+}
+
+#[test]
fn file_test_stat_is_correct_on_is_file() {
let tmpdir = tmpdir();
let filename = &tmpdir.join("file_stat_correct_on_is_file.txt");