From bd84fdbd2bb33997435b80c6ddcd12a9b4e2226d Mon Sep 17 00:00:00 2001 From: al8n Date: Wed, 30 Oct 2024 18:37:47 +0800 Subject: [PATCH] Update multiple_version_iters.rs --- src/swmr/tests/multiple_version_iters.rs | 32 +++++++++++++++++++----- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/swmr/tests/multiple_version_iters.rs b/src/swmr/tests/multiple_version_iters.rs index ee24a2c..1a96333 100644 --- a/src/swmr/tests/multiple_version_iters.rs +++ b/src/swmr/tests/multiple_version_iters.rs @@ -12,11 +12,11 @@ expand_unit_tests!("arena": MultipleVersionOrderWalArenaTable { }); expand_unit_tests!("linked": MultipleVersionOrderWalLinkedTable { - iter_all_versions_next, + iter_next, iter_all_versions_next_by_entry, iter_all_versions_next_by_versioned_entry, range_next, - iter_all_versions_prev, + iter_prev, range_prev, iter_all_versions_prev_by_entry, iter_all_versions_prev_by_versioned_entry, @@ -31,11 +31,11 @@ macro_rules! arena_builder { } expand_unit_tests!("arena": MultipleVersionOrderWalArenaTable { - iter_all_versions_next(arena_builder!()), + iter_next(arena_builder!()), iter_all_versions_next_by_entry(arena_builder!()), iter_all_versions_next_by_versioned_entry(arena_builder!()), range_next(arena_builder!()), - iter_all_versions_prev(arena_builder!()), + iter_prev(arena_builder!()), range_prev(arena_builder!()), iter_all_versions_prev_by_entry(arena_builder!()), iter_all_versions_prev_by_versioned_entry(arena_builder!()), @@ -89,7 +89,7 @@ where assert_eq!(num, 4); } -fn iter_all_versions_next(wal: &mut multiple_version::OrderWal) +fn iter_next(wal: &mut multiple_version::OrderWal) where M: MultipleVersionMemtable + 'static, M::Error: std::fmt::Debug, @@ -111,6 +111,16 @@ where } assert_eq!(i, N); + + let iter = wal.iter(0); + let mut i = 0; + for ent in iter { + assert_eq!(ent.key(), make_int_key(i).as_str()); + assert_eq!(ent.value(), make_value(i).as_str()); + i += 1; + } + + assert_eq!(i, N); } fn iter_all_versions_next_by_entry(wal: &mut multiple_version::OrderWal) @@ -208,7 +218,7 @@ where assert_eq!(i, 51); } -fn iter_all_versions_prev(wal: &mut multiple_version::OrderWal) +fn iter_prev(wal: &mut multiple_version::OrderWal) where M: MultipleVersionMemtable + 'static, M::Error: std::fmt::Debug, @@ -229,6 +239,16 @@ where } assert_eq!(i, 0); + + let iter = wal.iter(0).rev(); + let mut i = N; + for ent in iter { + assert_eq!(ent.key(), make_int_key(i - 1).as_str()); + assert_eq!(ent.value(), make_value(i - 1).as_str()); + i -= 1; + } + + assert_eq!(i, 0); } fn iter_all_versions_prev_by_entry(wal: &mut multiple_version::OrderWal)