some more tests
This commit is contained in:
@@ -347,59 +347,63 @@ mod tests {
|
|||||||
assert_eq!(ccsds_counter.get(), 0);
|
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().into(), 0);
|
||||||
assert_eq!(seq_counter.get_and_increment().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_and_increment().into(), 1);
|
||||||
assert_eq!(seq_counter.get().into(), 2);
|
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]
|
#[test]
|
||||||
fn test_atomic_counter_u8() {
|
fn test_atomic_counter_u8() {
|
||||||
let sync_u8_counter = AtomicU8::new(0);
|
let mut sync_u8_counter = AtomicU8::new(0);
|
||||||
common_couter_test(&sync_u8_counter);
|
common_counter_test(&mut sync_u8_counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_atomic_counter_u16() {
|
fn test_atomic_counter_u16() {
|
||||||
let sync_u16_counter = AtomicU16::new(0);
|
let mut sync_u16_counter = AtomicU16::new(0);
|
||||||
common_couter_test(&sync_u16_counter);
|
common_counter_test(&mut sync_u16_counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_atomic_counter_u32() {
|
fn test_atomic_counter_u32() {
|
||||||
let sync_u32_counter = AtomicU32::new(0);
|
let mut sync_u32_counter = AtomicU32::new(0);
|
||||||
common_couter_test(&sync_u32_counter);
|
common_counter_test(&mut sync_u32_counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_atomic_counter_u64() {
|
fn test_atomic_counter_u64() {
|
||||||
let sync_u64_counter = AtomicU64::new(0);
|
let mut sync_u64_counter = AtomicU64::new(0);
|
||||||
common_couter_test(&sync_u64_counter);
|
common_counter_test(&mut sync_u64_counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_portable_atomic_counter_u8() {
|
fn test_portable_atomic_counter_u8() {
|
||||||
let sync_u8_counter = portable_atomic::AtomicU8::new(0);
|
let mut sync_u8_counter = portable_atomic::AtomicU8::new(0);
|
||||||
common_couter_test(&sync_u8_counter);
|
common_counter_test(&mut sync_u8_counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_portable_atomic_counter_u16() {
|
fn test_portable_atomic_counter_u16() {
|
||||||
let sync_u16_counter = portable_atomic::AtomicU16::new(0);
|
let mut sync_u16_counter = portable_atomic::AtomicU16::new(0);
|
||||||
common_couter_test(&sync_u16_counter);
|
common_counter_test(&mut sync_u16_counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_portable_atomic_counter_u32() {
|
fn test_portable_atomic_counter_u32() {
|
||||||
let sync_u32_counter = portable_atomic::AtomicU32::new(0);
|
let mut sync_u32_counter = portable_atomic::AtomicU32::new(0);
|
||||||
common_couter_test(&sync_u32_counter);
|
common_counter_test(&mut sync_u32_counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_portable_atomic_counter_u64() {
|
fn test_portable_atomic_counter_u64() {
|
||||||
let sync_u64_counter = portable_atomic::AtomicU64::new(0);
|
let mut sync_u64_counter = portable_atomic::AtomicU64::new(0);
|
||||||
common_couter_test(&sync_u64_counter);
|
common_counter_test(&mut sync_u64_counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn common_overflow_test_u8(seq_counter: &impl SequenceCounter) {
|
fn common_overflow_test_u8(seq_counter: &impl SequenceCounter) {
|
||||||
|
|||||||
Reference in New Issue
Block a user