From e72c6d772667c65be6d936affb3d74d84255a797 Mon Sep 17 00:00:00 2001 From: Magnus Ulimoen Date: Tue, 28 Jan 2025 13:30:28 +0100 Subject: [PATCH] Fix read offset from current pos --- hdf5/tests/test_dataset.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hdf5/tests/test_dataset.rs b/hdf5/tests/test_dataset.rs index a54a214f..e010c95a 100644 --- a/hdf5/tests/test_dataset.rs +++ b/hdf5/tests/test_dataset.rs @@ -220,7 +220,7 @@ fn test_byte_read_seek_impl(ds: &hdf5::Dataset, arr: &ArrayD, ndim: usize) - // Seek from current position let orig_pos = reader.seek(SeekFrom::Start(pos)).expect("io::Seek failed") as i64; - let rel_pos = rng.random_range(-(arr.len() as i64)..arr.len() as i64 + 1); + let rel_pos = rng.random_range(-(orig_pos as i64)..(arr.len() as i64 - orig_pos) + 1); let pos_res = reader.seek(SeekFrom::Current(rel_pos)); if (rel_pos + orig_pos) < 0 { assert!(pos_res.is_err()) // We cannot seek before start