Skip to content

Commit af062b3

Browse files
committed
Update tests
1 parent 588953f commit af062b3

2 files changed

Lines changed: 82 additions & 1 deletion

File tree

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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 anon_0 {
10+
__bytes: Value<Box<[u8]>>,
11+
}
12+
impl anon_0 {
13+
pub fn bytes(&self) -> Ptr<Box<[u8]>> {
14+
(self.__bytes.as_pointer() as Ptr<u8>).reinterpret_cast()
15+
}
16+
pub fn aligner(&self) -> Ptr<AnyPtr> {
17+
(self.__bytes.as_pointer() as Ptr<u8>).reinterpret_cast()
18+
}
19+
}
20+
impl Clone for anon_0 {
21+
fn clone(&self) -> Self {
22+
anon_0 {
23+
__bytes: Rc::new(RefCell::new(self.__bytes.borrow().clone())),
24+
}
25+
}
26+
}
27+
impl Default for anon_0 {
28+
fn default() -> Self {
29+
anon_0 {
30+
__bytes: Rc::new(RefCell::new(Box::from([0u8; 8]))),
31+
}
32+
}
33+
}
34+
impl ByteRepr for anon_0 {
35+
fn byte_size() -> usize {
36+
8
37+
}
38+
fn to_bytes(&self, buf: &mut [u8]) {
39+
buf.copy_from_slice(&self.__bytes.borrow());
40+
}
41+
fn from_bytes(buf: &[u8]) -> Self {
42+
anon_0 {
43+
__bytes: Rc::new(RefCell::new(Box::from(buf))),
44+
}
45+
}
46+
}
47+
#[derive(Default)]
48+
pub struct node {
49+
pub next: Value<Ptr<node>>,
50+
pub x: Value<anon_0>,
51+
}
52+
impl ByteRepr for node {
53+
fn byte_size() -> usize {
54+
16
55+
}
56+
fn to_bytes(&self, buf: &mut [u8]) {
57+
(*self.next.borrow()).to_bytes(&mut buf[0..8]);
58+
(*self.x.borrow()).to_bytes(&mut buf[8..16]);
59+
}
60+
fn from_bytes(buf: &[u8]) -> Self {
61+
Self {
62+
next: Rc::new(RefCell::new(<Ptr<node>>::from_bytes(&buf[0..8]))),
63+
x: Rc::new(RefCell::new(<anon_0>::from_bytes(&buf[8..16]))),
64+
}
65+
}
66+
}
67+
pub fn main() {
68+
std::process::exit(main_0());
69+
}
70+
fn main_0() -> i32 {
71+
let n: Value<node> = <Value<node>>::default();
72+
(*(*n.borrow()).next.borrow_mut()) = Ptr::<node>::null();
73+
((*(*n.borrow()).x.borrow()).bytes().reinterpret_cast::<u8>() as Ptr<u8>)
74+
.offset((0) as isize)
75+
.write(171_u8);
76+
assert!(
77+
((((((*(*n.borrow()).x.borrow()).bytes().read())[(0) as usize] as i32) == 171) as i32)
78+
!= 0)
79+
);
80+
return 0;
81+
}

tests/unit/union_field_alignment.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// no-compile: refcount
1+
// panic: refcount
22
#include <assert.h>
33
#include <stddef.h>
44
#include <stdint.h>

0 commit comments

Comments
 (0)