Skip to content

Commit

Permalink
Add regression test for pr 767
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Jan 23, 2022
1 parent c6d6ff8 commit 1b41f9c
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions crossbeam-utils/tests/atomic_cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,41 @@ fn const_atomic_cell_new() {
assert_eq!(CELL.load(), 1);
}

// https://github.com/crossbeam-rs/crossbeam/pull/767
macro_rules! test_arithmetic {
($test_name:ident, $ty:ident) => {
#[test]
fn $test_name() {
let a: AtomicCell<$ty> = AtomicCell::new(7);

assert_eq!(a.fetch_add(3), 7);
assert_eq!(a.load(), 10);

assert_eq!(a.fetch_sub(3), 10);
assert_eq!(a.load(), 7);

assert_eq!(a.fetch_and(3), 7);
assert_eq!(a.load(), 3);

assert_eq!(a.fetch_or(16), 3);
assert_eq!(a.load(), 19);

assert_eq!(a.fetch_xor(2), 19);
assert_eq!(a.load(), 17);
}
};
}
test_arithmetic!(arithmetic_u8, u8);
test_arithmetic!(arithmetic_i8, i8);
test_arithmetic!(arithmetic_u16, u16);
test_arithmetic!(arithmetic_i16, i16);
test_arithmetic!(arithmetic_u32, u32);
test_arithmetic!(arithmetic_i32, i32);
test_arithmetic!(arithmetic_u64, u64);
test_arithmetic!(arithmetic_i64, i64);
test_arithmetic!(arithmetic_u128, u128);
test_arithmetic!(arithmetic_i128, i128);

// https://github.com/crossbeam-rs/crossbeam/issues/748
#[cfg_attr(miri, ignore)] // TODO
#[rustversion::since(1.37)] // #[repr(align(N))] requires Rust 1.37
Expand Down

0 comments on commit 1b41f9c

Please sign in to comment.