Skip to content

Commit bb3cc72

Browse files
committed
Update tests
1 parent e7c656c commit bb3cc72

8 files changed

Lines changed: 20 additions & 33 deletions

File tree

tests/unit/out/refcount/c_struct.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,22 @@ use libcc2rs::*;
33
use std::cell::RefCell;
44
use std::collections::BTreeMap;
55
use std::io::prelude::*;
6-
use std::io::Seek;
7-
use std::io::{Read, Write};
6+
use std::io::{Read, Seek, Write};
87
use std::os::fd::AsFd;
98
use std::rc::{Rc, Weak};
10-
#[derive(Clone, Default)]
9+
#[derive(Default)]
1110
pub struct Point {
1211
pub x: Value<i32>,
1312
pub y: Value<i32>,
1413
}
1514
impl ByteRepr for Point {}
16-
#[derive(Clone, Default)]
15+
#[derive(Default)]
1716
pub struct Line {
1817
pub start: Value<Point>,
1918
pub end: Value<Point>,
2019
}
2120
impl ByteRepr for Line {}
22-
#[derive(Clone, Default)]
21+
#[derive(Default)]
2322
pub struct Node {
2423
pub value: Value<i32>,
2524
pub next: Value<Ptr<Node>>,
@@ -32,13 +31,13 @@ enum Color {
3231
GREEN = 1,
3332
BLUE = 2,
3433
}
35-
#[derive(Clone, Default)]
34+
#[derive(Default)]
3635
pub struct Inner {
3736
pub a: Value<i32>,
3837
pub b: Value<i32>,
3938
}
4039
impl ByteRepr for Inner {}
41-
#[derive(Clone, Default)]
40+
#[derive(Default)]
4241
pub struct Container {
4342
pub inner: Value<Inner>,
4443
pub color: Value<Color>,

tests/unit/out/refcount/va_arg_struct_ctx.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,6 @@ pub struct context {
1111
pub verbose: Value<i32>,
1212
pub last_error: Value<i32>,
1313
}
14-
impl Clone for context {
15-
fn clone(&self) -> Self {
16-
let mut this = Self {
17-
verbose: Rc::new(RefCell::new((*self.verbose.borrow()))),
18-
last_error: Rc::new(RefCell::new((*self.last_error.borrow()))),
19-
};
20-
this
21-
}
22-
}
2314
impl ByteRepr for context {}
2415
pub fn set_error_0(ctx: Ptr<context>, fmt: Ptr<u8>, args: &[VaArg]) {
2516
let ctx: Value<Ptr<context>> = Rc::new(RefCell::new(ctx));
@@ -35,7 +26,7 @@ pub fn main() {
3526
std::process::exit(main_0());
3627
}
3728
fn main_0() -> i32 {
38-
let ctx: Value<context> = Rc::new(RefCell::new(<context>::default()));
29+
let ctx: Value<context> = <Value<context>>::default();
3930
(*(*ctx.borrow()).verbose.borrow_mut()) = 1;
4031
(*(*ctx.borrow()).last_error.borrow_mut()) = 0;
4132
({

tests/unit/out/unsafe/c_struct.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,20 @@ use libc::*;
33
extern crate libcc2rs;
44
use libcc2rs::*;
55
use std::collections::BTreeMap;
6-
use std::io::Seek;
7-
use std::io::{Read, Write};
6+
use std::io::{Read, Seek, Write};
87
use std::os::fd::{AsFd, FromRawFd, IntoRawFd};
98
use std::rc::Rc;
10-
#[derive(Clone, Default)]
9+
#[derive(Copy, Clone, Default)]
1110
pub struct Point {
1211
pub x: i32,
1312
pub y: i32,
1413
}
15-
#[derive(Clone, Default)]
14+
#[derive(Copy, Clone, Default)]
1615
pub struct Line {
1716
pub start: Point,
1817
pub end: Point,
1918
}
20-
#[derive(Clone, Default)]
19+
#[derive(Copy, Clone, Default)]
2120
pub struct Node {
2221
pub value: i32,
2322
pub next: *mut Node,
@@ -29,12 +28,12 @@ enum Color {
2928
GREEN = 1,
3029
BLUE = 2,
3130
}
32-
#[derive(Clone, Default)]
31+
#[derive(Copy, Clone, Default)]
3332
pub struct Inner {
3433
pub a: i32,
3534
pub b: i32,
3635
}
37-
#[derive(Clone, Default)]
36+
#[derive(Copy, Clone, Default)]
3837
pub struct Container {
3938
pub inner: Inner,
4039
pub color: Color,

tests/unit/out/unsafe/va_arg_concat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub unsafe fn sum_ints_0(mut first: i32, args: &[VaArg]) -> i32 {
1010
let mut ap: VaList = VaList::default();
1111
let mut total: i32 = first;
1212
ap = VaList::new(args);
13-
let mut val: i32 = <i32>::default();
13+
let mut val: i32 = 0_i32;
1414
'loop_: while ((({
1515
val = ap.arg::<i32>();
1616
val

tests/unit/out/unsafe/va_arg_snprintf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub fn main() {
2424
}
2525
}
2626
unsafe fn main_0() -> i32 {
27-
let mut buf: [u8; 64] = [<u8>::default(); 64];
27+
let mut buf: [u8; 64] = [0_u8; 64];
2828
assert!(
2929
((unsafe {
3030
let _buf: *mut u8 = buf.as_mut_ptr();

tests/unit/out/unsafe/va_arg_two_passes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub unsafe fn sum_then_product_0(mut first: i32, args: &[VaArg]) -> i32 {
1111
let mut sum: i32 = first;
1212
let mut product: i32 = first;
1313
ap = VaList::new(args);
14-
let mut val: i32 = <i32>::default();
14+
let mut val: i32 = 0_i32;
1515
'loop_: while ((({
1616
val = ap.arg::<i32>();
1717
val

tests/unit/va_arg_chain.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ int extract_nth(int n, va_list ap) {
88
return va_arg(ap, int);
99
}
1010

11-
int middle_layer(int n, va_list ap) {
12-
return extract_nth(n, ap);
13-
}
11+
int middle_layer(int n, va_list ap) { return extract_nth(n, ap); }
1412

1513
int top_level(int n, ...) {
1614
va_list ap;

tests/unit/va_arg_promotion.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ int test_promotions(int count, ...) {
66
va_start(ap, count);
77

88
// char and short are promoted to int by the caller
9-
int a = va_arg(ap, int); // was passed as char 'A' (65)
10-
int b = va_arg(ap, int); // was passed as short 10
9+
int a = va_arg(ap, int); // was passed as char 'A' (65)
10+
int b = va_arg(ap, int); // was passed as short 10
1111

1212
// float is promoted to double by the caller
13-
double c = va_arg(ap, double); // was passed as float 3.0
13+
double c = va_arg(ap, double); // was passed as float 3.0
1414

1515
va_end(ap);
1616

0 commit comments

Comments
 (0)