From a14f6d2be8c878cb16e1c23fb79c46245a24e036 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 9 Sep 2025 13:33:54 +0200 Subject: [PATCH] some more tests --- src/seq_count.rs | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/seq_count.rs b/src/seq_count.rs index 97e4cad..ad14395 100644 --- a/src/seq_count.rs +++ b/src/seq_count.rs @@ -347,59 +347,63 @@ mod tests { assert_eq!(ccsds_counter.get(), 0); } - fn common_couter_test(seq_counter: &impl SequenceCounter) { + fn common_counter_test(seq_counter: &mut impl SequenceCounter) { assert_eq!(seq_counter.get().into(), 0); assert_eq!(seq_counter.get_and_increment().into(), 0); assert_eq!(seq_counter.get_and_increment().into(), 1); assert_eq!(seq_counter.get().into(), 2); + seq_counter.increment_mut(); + assert_eq!(seq_counter.get().into(), 3); + assert_eq!(seq_counter.get_and_increment_mut().into(), 3); + assert_eq!(seq_counter.get().into(), 4); } #[test] fn test_atomic_counter_u8() { - let sync_u8_counter = AtomicU8::new(0); - common_couter_test(&sync_u8_counter); + let mut sync_u8_counter = AtomicU8::new(0); + common_counter_test(&mut sync_u8_counter); } #[test] fn test_atomic_counter_u16() { - let sync_u16_counter = AtomicU16::new(0); - common_couter_test(&sync_u16_counter); + let mut sync_u16_counter = AtomicU16::new(0); + common_counter_test(&mut sync_u16_counter); } #[test] fn test_atomic_counter_u32() { - let sync_u32_counter = AtomicU32::new(0); - common_couter_test(&sync_u32_counter); + let mut sync_u32_counter = AtomicU32::new(0); + common_counter_test(&mut sync_u32_counter); } #[test] fn test_atomic_counter_u64() { - let sync_u64_counter = AtomicU64::new(0); - common_couter_test(&sync_u64_counter); + let mut sync_u64_counter = AtomicU64::new(0); + common_counter_test(&mut sync_u64_counter); } #[test] fn test_portable_atomic_counter_u8() { - let sync_u8_counter = portable_atomic::AtomicU8::new(0); - common_couter_test(&sync_u8_counter); + let mut sync_u8_counter = portable_atomic::AtomicU8::new(0); + common_counter_test(&mut sync_u8_counter); } #[test] fn test_portable_atomic_counter_u16() { - let sync_u16_counter = portable_atomic::AtomicU16::new(0); - common_couter_test(&sync_u16_counter); + let mut sync_u16_counter = portable_atomic::AtomicU16::new(0); + common_counter_test(&mut sync_u16_counter); } #[test] fn test_portable_atomic_counter_u32() { - let sync_u32_counter = portable_atomic::AtomicU32::new(0); - common_couter_test(&sync_u32_counter); + let mut sync_u32_counter = portable_atomic::AtomicU32::new(0); + common_counter_test(&mut sync_u32_counter); } #[test] fn test_portable_atomic_counter_u64() { - let sync_u64_counter = portable_atomic::AtomicU64::new(0); - common_couter_test(&sync_u64_counter); + let mut sync_u64_counter = portable_atomic::AtomicU64::new(0); + common_counter_test(&mut sync_u64_counter); } fn common_overflow_test_u8(seq_counter: &impl SequenceCounter) {