Skip to content

Commit dd535c6

Browse files
committed
Add expected file for union_basic
1 parent db6bfda commit dd535c6

2 files changed

Lines changed: 75 additions & 0 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
extern crate libcc2rs;
2+
use libcc2rs::*;
3+
use std::cell::RefCell;
4+
use std::collections::BTreeMap;
5+
use std::io::prelude::*;
6+
use std::io::{Read, Seek, Write};
7+
use std::os::fd::AsFd;
8+
use std::rc::{Rc, Weak};
9+
pub struct basic {
10+
__buf: Rc<RefCell<Vec<u8>>>,
11+
pub i: Value<i32>,
12+
pub f: Value<f32>,
13+
}
14+
impl Default for basic {
15+
fn default() -> Self {
16+
let __buf = Rc::new(RefCell::new(vec![0u8; 4]));
17+
Self {
18+
__buf: __buf.clone(),
19+
i: Value::new_reinterpreted(
20+
Rc::new(SliceOriginalAlloc {
21+
weak: Rc::downgrade(&__buf),
22+
}),
23+
0,
24+
),
25+
f: Value::new_reinterpreted(
26+
Rc::new(SliceOriginalAlloc {
27+
weak: Rc::downgrade(&__buf),
28+
}),
29+
0,
30+
),
31+
}
32+
}
33+
}
34+
impl ByteRepr for basic {}
35+
pub fn main() {
36+
std::process::exit(main_0());
37+
}
38+
fn main_0() -> i32 {
39+
let u: Value<basic> = <Value<basic>>::default();
40+
(*u.borrow()).i.write(42);
41+
assert!(((*u.borrow()).i.read() == 42));
42+
(*u.borrow()).f.write(3.140000105E+0);
43+
assert!(((*u.borrow()).f.read() == 3.140000105E+0));
44+
return 0;
45+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
extern crate libc;
2+
use libc::*;
3+
extern crate libcc2rs;
4+
use libcc2rs::*;
5+
use std::collections::BTreeMap;
6+
use std::io::{Read, Seek, Write};
7+
use std::os::fd::{AsFd, FromRawFd, IntoRawFd};
8+
use std::rc::Rc;
9+
pub union basic {
10+
pub i: i32,
11+
pub f: f32,
12+
}
13+
impl Default for basic {
14+
fn default() -> Self {
15+
unsafe { ::std::mem::MaybeUninit::zeroed().assume_init() }
16+
}
17+
}
18+
pub fn main() {
19+
unsafe {
20+
std::process::exit(main_0() as i32);
21+
}
22+
}
23+
unsafe fn main_0() -> i32 {
24+
let mut u: basic = <basic>::default();
25+
u.i = 42;
26+
assert!(((u.i) == (42)));
27+
u.f = 3.140000105E+0;
28+
assert!(((u.f) == (3.140000105E+0)));
29+
return 0;
30+
}

0 commit comments

Comments
 (0)