Skip to content

Commit 9e08951

Browse files
committed
Update tests
1 parent 038db66 commit 9e08951

6 files changed

Lines changed: 44 additions & 4 deletions

File tree

‎libcc2rs/src/dec.rs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,14 @@ macro_rules! prefix_wrap_dec_impl {
5959
};
6060
}
6161

62-
postfix_wrap_dec_impl!(i8, u8, i16, u16, i32, u32, i64, u64, i128, u128, isize, usize);
62+
postfix_wrap_dec_impl!(
63+
i8, u8, i16, u16, i32, u32, i64, u64, i128, u128, isize, usize
64+
);
6365
postfix_nowrap_dec_impl!(f32, f64);
6466

65-
prefix_wrap_dec_impl!(i8, u8, i16, u16, i32, u32, i64, u64, i128, u128, isize, usize);
67+
prefix_wrap_dec_impl!(
68+
i8, u8, i16, u16, i32, u32, i64, u64, i128, u128, isize, usize
69+
);
6670
prefix_nowrap_dec_impl!(f32, f64);
6771

6872
pub trait UnsafePostfixDec {

‎libcc2rs/src/inc.rs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,14 @@ macro_rules! prefix_wrap_inc_impl {
5959
};
6060
}
6161

62-
prefix_wrap_inc_impl!(i8, u8, i16, u16, i32, u32, i64, u64, i128, u128, isize, usize);
62+
prefix_wrap_inc_impl!(
63+
i8, u8, i16, u16, i32, u32, i64, u64, i128, u128, isize, usize
64+
);
6365
prefix_nowrap_inc_impl!(f32, f64);
6466

65-
postfix_wrap_inc_impl!(i8, u8, i16, u16, i32, u32, i64, u64, i128, u128, isize, usize);
67+
postfix_wrap_inc_impl!(
68+
i8, u8, i16, u16, i32, u32, i64, u64, i128, u128, isize, usize
69+
);
6670
postfix_nowrap_inc_impl!(f32, f64);
6771

6872
pub trait UnsafePostfixInc {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ fn main_0() -> i32 {
4545
i.prefix_inc();
4646
}
4747
assert!((out == 51));
48+
let mut step: i64 = 2_i64;
49+
let mut offset: Ptr<i32> = (arr.as_pointer() as Ptr<i32>).offset((step) as isize);
50+
assert!(({ (offset.read()) } == { (*arr.borrow())[(2) as usize] }));
51+
offset = { offset.offset(-((step) as isize)) };
52+
assert!(({ (offset).clone() } == { ((arr.as_pointer() as Ptr<i32>).offset(0)) }));
4853
return 0;
4954
}
5055
pub fn __cpp2rust_init_globals() {}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ fn main_0() -> i32 {
3131
assert!((d == 1.5E+0));
3232
assert!(((n + n) == (2 * x2)));
3333
assert!((a[(0) as usize] == a[(0) as usize]));
34+
let mut wide: i128 = 5_i128;
35+
let mut w1: i128 = wide.postfix_inc();
36+
let mut w2: i128 = wide.prefix_inc();
37+
let mut w3: i128 = wide.postfix_dec();
38+
let mut w4: i128 = wide.prefix_dec();
39+
assert!((((w1 == 5_i128) && (w2 == 7_i128)) && (w3 == 7_i128)) && (w4 == 5_i128));
40+
let mut uwide: u128 = 0_u128;
41+
uwide.prefix_dec();
42+
uwide.postfix_inc();
43+
assert!((uwide == 0_u128));
3444
return 0;
3545
}
3646
pub fn __cpp2rust_init_globals() {}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ unsafe fn main_0() -> i32 {
4747
i.prefix_inc();
4848
}
4949
assert!(((out) == (51)));
50+
let mut step: i64 = 2_i64;
51+
let mut offset: *mut i32 = arr.as_mut_ptr().offset((step) as isize);
52+
assert!(((*offset) == (arr[(2) as usize])));
53+
offset = offset.offset(-((step) as isize));
54+
assert!(((offset) == (&mut arr[(0) as usize] as *mut i32)));
5055
return 0;
5156
}
5257
pub unsafe fn __cpp2rust_init_globals() {}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ unsafe fn main_0() -> i32 {
3333
assert!(((d) == (1.5E+0)));
3434
assert!((((n) + (n)) == ((2) * (x2))));
3535
assert!(((a[(0) as usize]) == (a[(0) as usize])));
36+
let mut wide: i128 = 5_i128;
37+
let mut w1: i128 = wide.postfix_inc();
38+
let mut w2: i128 = wide.prefix_inc();
39+
let mut w3: i128 = wide.postfix_dec();
40+
let mut w4: i128 = wide.prefix_dec();
41+
assert!(
42+
((((w1) == (5_i128)) && ((w2) == (7_i128))) && ((w3) == (7_i128))) && ((w4) == (5_i128))
43+
);
44+
let mut uwide: u128 = 0_u128;
45+
uwide.prefix_dec();
46+
uwide.postfix_inc();
47+
assert!(((uwide) == (0_u128)));
3648
return 0;
3749
}
3850
pub unsafe fn __cpp2rust_init_globals() {}

0 commit comments

Comments
 (0)