Skip to content

Commit ff1aa9f

Browse files
committed
crux-mir: add tests for load/store and drop of zsts
1 parent b1ac514 commit ff1aa9f

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//! Test drop for zero-sized types.
2+
use std::sync::atomic::{AtomicUsize, Ordering};
3+
4+
static DROPPED: AtomicUsize = AtomicUsize::new(0);
5+
6+
struct S;
7+
impl Drop for S {
8+
fn drop(&mut self) {
9+
DROPPED.fetch_add(1, Ordering::Relaxed);
10+
}
11+
}
12+
13+
fn f<T>(x: T) {}
14+
15+
#[cfg_attr(crux, crux::test)]
16+
fn crux_test() -> usize {
17+
{
18+
let s = S;
19+
let s2 = (S,);
20+
f(s2);
21+
}
22+
DROPPED.load(Ordering::Relaxed)
23+
}
24+
25+
pub fn main() {
26+
println!("{:?}", crux_test());
27+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
fn my_replace<T: Clone>(r: &mut T, x: T) -> T {
2+
let old = (*r).clone();
3+
*r = x;
4+
old
5+
}
6+
7+
#[cfg_attr(crux, crux::test)]
8+
fn crux_test() {
9+
let mut x = ();
10+
my_replace(&mut x, ());
11+
let mut y = (1, ());
12+
my_replace(&mut y.1, ());
13+
}
14+
15+
pub fn main() {
16+
println!("{:?}", crux_test());
17+
}

0 commit comments

Comments
 (0)