test/file_sector_source: drop buf-state assertions after 0.21.3 bypass
The three tests (multi_sector_read_spanning_buffer_boundary, backward_seek_rebuffers, partial_buffer_at_eof) were asserting internal buf_start_lba / buf_len_sectors state. With 0.21.3's read-path bypass, those fields are no longer mutated. The byte-level contract assertions (read returns correct bytes for every scenario the tests cover) remain intact.
This commit is contained in:
@@ -290,14 +290,14 @@ mod tests {
|
|||||||
|
|
||||||
let mut src = FileSectorSource::open(&path).unwrap();
|
let mut src = FileSectorSource::open(&path).unwrap();
|
||||||
|
|
||||||
// Prime: read sector 0 to populate buffer #0.
|
// Prime: read sector 0. (0.21.3+: app-level buffer is bypassed,
|
||||||
|
// so we don't assert internal buf state here — just exercise
|
||||||
|
// the read path.)
|
||||||
let mut got = vec![0u8; SECTOR_SIZE];
|
let mut got = vec![0u8; SECTOR_SIZE];
|
||||||
src.read_sectors(0, 1, &mut got, false).unwrap();
|
src.read_sectors(0, 1, &mut got, false).unwrap();
|
||||||
assert_eq!(src.buf_start_lba, 0);
|
|
||||||
assert!(src.buf_len_sectors > 0);
|
|
||||||
|
|
||||||
// Now read 4 sectors crossing the buffer boundary at
|
// Now read 4 sectors crossing what used to be the buffer
|
||||||
// BUF_SECTORS - 2 → BUF_SECTORS + 1. Spans the refill.
|
// boundary. Still a valid SectorSource-contract test.
|
||||||
let span_lba = BUF_SECTORS - 2;
|
let span_lba = BUF_SECTORS - 2;
|
||||||
let mut buf4 = vec![0u8; SECTOR_SIZE * 4];
|
let mut buf4 = vec![0u8; SECTOR_SIZE * 4];
|
||||||
src.read_sectors(span_lba, 4, &mut buf4, false).unwrap();
|
src.read_sectors(span_lba, 4, &mut buf4, false).unwrap();
|
||||||
@@ -325,13 +325,11 @@ mod tests {
|
|||||||
// Forward to the second window.
|
// Forward to the second window.
|
||||||
src.read_sectors(BUF_SECTORS + 1, 1, &mut got, false)
|
src.read_sectors(BUF_SECTORS + 1, 1, &mut got, false)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let start_after_forward = src.buf_start_lba;
|
|
||||||
assert!(start_after_forward >= BUF_SECTORS);
|
|
||||||
|
|
||||||
// Backward to sector 0. The current buffer doesn't cover it
|
// Backward to sector 0. (0.21.3+: app-level buffer is bypassed
|
||||||
// → refill must happen.
|
// so we only assert the byte-level contract, not internal
|
||||||
|
// buffer state.)
|
||||||
src.read_sectors(0, 1, &mut got, false).unwrap();
|
src.read_sectors(0, 1, &mut got, false).unwrap();
|
||||||
assert_eq!(src.buf_start_lba, 0);
|
|
||||||
assert!(got.iter().all(|b| *b == 0));
|
assert!(got.iter().all(|b| *b == 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,11 +348,12 @@ mod tests {
|
|||||||
assert_eq!(src.capacity_sectors(), total);
|
assert_eq!(src.capacity_sectors(), total);
|
||||||
|
|
||||||
let mut got = vec![0u8; SECTOR_SIZE];
|
let mut got = vec![0u8; SECTOR_SIZE];
|
||||||
// First read triggers refill clamped to `total`.
|
// First read at sector 0.
|
||||||
src.read_sectors(0, 1, &mut got, false).unwrap();
|
src.read_sectors(0, 1, &mut got, false).unwrap();
|
||||||
assert_eq!(src.buf_len_sectors, total);
|
|
||||||
|
|
||||||
// Read the very last sector — still inside the buffer.
|
// Read the very last sector. (0.21.3+: app-level buffer is
|
||||||
|
// bypassed; the test still verifies that EOF-region reads
|
||||||
|
// return correct bytes.)
|
||||||
src.read_sectors(total - 1, 1, &mut got, false).unwrap();
|
src.read_sectors(total - 1, 1, &mut got, false).unwrap();
|
||||||
let expected = ((total - 1) & 0xff) as u8;
|
let expected = ((total - 1) & 0xff) as u8;
|
||||||
assert!(got.iter().all(|b| *b == expected));
|
assert!(got.iter().all(|b| *b == expected));
|
||||||
|
|||||||
Reference in New Issue
Block a user