Skip to content

Commit

Permalink
Add new test.
Browse files Browse the repository at this point in the history
Based on #131
  • Loading branch information
thejpster committed Jun 1, 2024
1 parent 44b63de commit 83128a3
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/read_file_with_seek.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
mod utils;

static FILE_TO_READ: &str = "64MB.DAT";

#[test]
fn read_file_with_seek() {
let time_source = utils::make_time_source();
let disk = utils::make_block_device(utils::DISK_SOURCE).unwrap();
let mut volume_mgr = embedded_sdmmc::VolumeManager::new(disk, time_source);

let mut volume = volume_mgr
.open_volume(embedded_sdmmc::VolumeIdx(0))
.unwrap();
let mut root_dir = volume.open_root_dir().unwrap();
println!("\nReading file {}...", FILE_TO_READ);
let mut f = root_dir
.open_file_in_dir(FILE_TO_READ, embedded_sdmmc::Mode::ReadOnly)
.unwrap();
f.seek_from_start(0x2c).unwrap();
while f.offset() < 1000000 {
let mut buffer = [0u8; 2048];
f.read(&mut buffer).unwrap();
f.seek_from_current(-1024).unwrap();
}
println!("Done!");
}

0 comments on commit 83128a3

Please sign in to comment.