Skip to content

Commit 96cd270

Browse files
committed
Update tests
1 parent 32d916a commit 96cd270

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

tests/unit/out/refcount/tag_vs_identifier_collision.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ pub struct widget {
3838
pub mode: Value<widget_enum>,
3939
}
4040
impl ByteRepr for widget {
41+
fn byte_size() -> usize {
42+
8
43+
}
4144
fn to_bytes(&self, buf: &mut [u8]) {
4245
(*self.id.borrow()).to_bytes(&mut buf[0..4]);
4346
(*self.mode.borrow()).to_bytes(&mut buf[4..8]);
@@ -55,6 +58,9 @@ pub struct point_struct {
5558
pub y: Value<i32>,
5659
}
5760
impl ByteRepr for point_struct {
61+
fn byte_size() -> usize {
62+
8
63+
}
5864
fn to_bytes(&self, buf: &mut [u8]) {
5965
(*self.x.borrow()).to_bytes(&mut buf[0..4]);
6066
(*self.y.borrow()).to_bytes(&mut buf[4..8]);
@@ -147,6 +153,9 @@ pub struct Inner {
147153
pub tag_field: Value<i32>,
148154
}
149155
impl ByteRepr for Inner {
156+
fn byte_size() -> usize {
157+
4
158+
}
150159
fn to_bytes(&self, buf: &mut [u8]) {
151160
(*self.tag_field.borrow()).to_bytes(&mut buf[0..4]);
152161
}
@@ -160,12 +169,27 @@ impl ByteRepr for Inner {
160169
pub struct Outer {
161170
pub field: Value<Inner>,
162171
}
163-
impl ByteRepr for Outer {}
172+
impl ByteRepr for Outer {
173+
fn byte_size() -> usize {
174+
4
175+
}
176+
fn to_bytes(&self, buf: &mut [u8]) {
177+
(*self.field.borrow()).to_bytes(&mut buf[0..4]);
178+
}
179+
fn from_bytes(buf: &[u8]) -> Self {
180+
Self {
181+
field: Rc::new(RefCell::new(<Inner>::from_bytes(&buf[0..4]))),
182+
}
183+
}
184+
}
164185
#[derive(Default)]
165186
pub struct Inner_struct {
166187
pub typedef_field: Value<i32>,
167188
}
168189
impl ByteRepr for Inner_struct {
190+
fn byte_size() -> usize {
191+
4
192+
}
169193
fn to_bytes(&self, buf: &mut [u8]) {
170194
(*self.typedef_field.borrow()).to_bytes(&mut buf[0..4]);
171195
}

tests/unit/out/refcount/union_tagged_struct_arms.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ pub struct anon_2 {
4747
pub step: Value<u8>,
4848
}
4949
impl ByteRepr for anon_2 {
50+
fn byte_size() -> usize {
51+
16
52+
}
5053
fn to_bytes(&self, buf: &mut [u8]) {
5154
(*self.lo.borrow()).to_bytes(&mut buf[0..4]);
5255
(*self.hi.borrow()).to_bytes(&mut buf[4..8]);
@@ -71,6 +74,9 @@ pub struct anon_3 {
7174
pub width: Value<i32>,
7275
}
7376
impl ByteRepr for anon_3 {
77+
fn byte_size() -> usize {
78+
40
79+
}
7480
fn to_bytes(&self, buf: &mut [u8]) {
7581
(*self.lo.borrow()).to_bytes(&mut buf[0..8]);
7682
(*self.hi.borrow()).to_bytes(&mut buf[8..16]);

0 commit comments

Comments
 (0)