Skip to content

Commit 7c7b3bd

Browse files
committed
Update tests
1 parent 24a32cd commit 7c7b3bd

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

‎tests/unit/out/refcount/union_basic.rs‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ fn main_0() -> i32 {
9393
assert!(((basic::i(ru.clone()).read()) == 1065353216));
9494
assert!(((pf.read()) == 1_f32));
9595
assert!((((*buf.borrow())[(3) as usize] as i32) == 63));
96+
{
97+
let anon_0: Value<anon_0> = Rc::new(RefCell::new(<anon_0>::default()));
98+
anon_0::ai(anon_0.as_pointer()).write(11);
99+
assert!(((anon_0::ai(anon_0.as_pointer()).read()) == 11));
100+
anon_0::ai(anon_0.as_pointer()).write(1065353216);
101+
assert!(((anon_0::af(anon_0.as_pointer()).read()) == 1_f32));
102+
}
96103
let us: Value<underscores> = Rc::new(RefCell::new(<underscores>::default()));
97104
underscores::__(us.as_pointer()).write(5);
98105
assert!(((underscores::__(us.as_pointer()).read()) == 5));
@@ -103,4 +110,26 @@ fn main_0() -> i32 {
103110
assert!(((__ + ___) == 3));
104111
return 0;
105112
}
113+
#[derive(VaArg, FnPtrArg, ByteRepr, DeepClone)]
114+
#[byte_size(4)]
115+
pub struct anon_0 {
116+
#[offset(0)]
117+
#[byte_size(4)]
118+
__bytes: Value<Box<[u8]>>,
119+
}
120+
impl anon_0 {
121+
pub fn ai(this: Ptr<Self>) -> Ptr<i32> {
122+
this.reinterpret_cast()
123+
}
124+
pub fn af(this: Ptr<Self>) -> Ptr<f32> {
125+
this.reinterpret_cast()
126+
}
127+
}
128+
impl Default for anon_0 {
129+
fn default() -> Self {
130+
anon_0 {
131+
__bytes: Rc::new(RefCell::new(Box::from([0u8; 4]))),
132+
}
133+
}
134+
}
106135
pub fn __cpp2rust_init_globals() {}

‎tests/unit/out/unsafe/union_basic.rs‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ unsafe fn main_0() -> i32 {
6969
assert!((((*ru).i) == (1065353216)));
7070
assert!(((*pf) == (1_f32)));
7171
assert!(((buf[(3) as usize] as i32) == (63)));
72+
{
73+
let mut anon_0: anon_0 = <anon_0>::default();
74+
anon_0.ai = 11;
75+
assert!(((anon_0.ai) == (11)));
76+
anon_0.ai = 1065353216;
77+
assert!(((anon_0.af) == (1_f32)));
78+
}
7279
let mut us: underscores = <underscores>::default();
7380
us.__ = 5;
7481
assert!(((us.__) == (5)));
@@ -79,4 +86,15 @@ unsafe fn main_0() -> i32 {
7986
assert!((((__) + (___)) == (3)));
8087
return 0;
8188
}
89+
#[repr(C)]
90+
#[derive(Copy, Clone, FnPtrArg, VaArg)]
91+
pub union anon_0 {
92+
pub ai: i32,
93+
pub af: f32,
94+
}
95+
impl Default for anon_0 {
96+
fn default() -> Self {
97+
unsafe { std::mem::zeroed() }
98+
}
99+
}
82100
pub unsafe fn __cpp2rust_init_globals() {}

0 commit comments

Comments
 (0)