Skip to content

Commit 6d2136c

Browse files
committed
test AtomicU64
1 parent d28fce0 commit 6d2136c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

tests/run-pass/atomic.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
use std::sync::atomic::{AtomicBool, AtomicIsize, Ordering::*};
1+
use std::sync::atomic::{AtomicBool, AtomicIsize, AtomicU64, Ordering::*};
22

33
fn main() {
44
atomic_bool();
55
atomic_isize();
6+
atomic_u64();
67
}
78

89
fn atomic_bool() {
@@ -50,3 +51,12 @@ fn atomic_isize() {
5051
ATOMIC.compare_exchange_weak(0, 1, SeqCst, Acquire).ok();
5152
ATOMIC.compare_exchange_weak(0, 1, SeqCst, SeqCst).ok();
5253
}
54+
55+
fn atomic_u64() {
56+
static ATOMIC: AtomicU64 = AtomicU64::new(0);
57+
58+
ATOMIC.store(1, SeqCst);
59+
assert_eq!(ATOMIC.compare_exchange(0, 0x100, AcqRel, Acquire), Err(1));
60+
assert_eq!(ATOMIC.compare_exchange_weak(1, 0x100, AcqRel, Acquire), Ok(1));
61+
assert_eq!(ATOMIC.load(Relaxed), 0x100);
62+
}

0 commit comments

Comments
 (0)