Skip to content

Commit ea32d9b

Browse files
committed
Update tests
1 parent 6736f2a commit ea32d9b

4 files changed

Lines changed: 170 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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+
impl p1_template_constructor_from_own_type_Probe {
10+
pub fn new_1(u: Ptr<p1_template_constructor_from_own_type_Probe>) -> Self {
11+
Self {
12+
value: (u.with(|__s| __s.value) + 1),
13+
}
14+
}
15+
}
16+
#[derive(Clone, Record, ByteRepr, VaArg, FnPtrArg, CppFrom, Default)]
17+
#[cpp_from(i32, new_2, value)]
18+
#[byte_size(4)]
19+
pub struct p1_template_constructor_from_own_type_Probe {
20+
#[offset(0)]
21+
pub value: i32,
22+
}
23+
impl p1_template_constructor_from_own_type_Probe {
24+
pub fn new_2(mut v: i32) -> Self {
25+
Self { value: v }
26+
}
27+
}
28+
pub fn test_0() {
29+
let probe: Value<p1_template_constructor_from_own_type_Probe> = Rc::new(RefCell::new(
30+
p1_template_constructor_from_own_type_Probe::new_2({ 22 }),
31+
));
32+
let mut converted: p1_template_constructor_from_own_type_Probe =
33+
p1_template_constructor_from_own_type_Probe::new_1({ probe.as_pointer() });
34+
assert!((converted.value == 23));
35+
}
36+
pub fn main() {
37+
__cpp2rust_init_globals();
38+
std::process::exit(main_0());
39+
}
40+
fn main_0() -> i32 {
41+
({ test_0() });
42+
return 0;
43+
}
44+
pub fn __cpp2rust_init_globals() {}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
#[derive(Clone, Record, ByteRepr, VaArg, FnPtrArg, CppFrom, Default)]
10+
#[cpp_into(i64, to_i64, mut_ptr)]
11+
#[byte_size(8)]
12+
pub struct p2_non_const_conversion_function_Gauge {
13+
#[offset(0)]
14+
pub value: i64,
15+
}
16+
pub fn test_0() {
17+
let gauge: Value<p2_non_const_conversion_function_Gauge> =
18+
Rc::new(RefCell::new(p2_non_const_conversion_function_Gauge {
19+
value: 20_i64,
20+
}));
21+
let mut converted: i64 =
22+
({ p2_non_const_conversion_function_GaugeImpl::to_i64(&gauge.as_pointer()) });
23+
assert!((converted == 21_i64));
24+
assert!(({ ({ (*gauge.borrow()).value } == 21_i64) }));
25+
}
26+
pub fn main() {
27+
__cpp2rust_init_globals();
28+
std::process::exit(main_0());
29+
}
30+
fn main_0() -> i32 {
31+
({ test_0() });
32+
return 0;
33+
}
34+
pub trait p2_non_const_conversion_function_GaugeImpl {
35+
fn to_i64(&self) -> i64;
36+
}
37+
impl p2_non_const_conversion_function_GaugeImpl for Ptr<p2_non_const_conversion_function_Gauge> {
38+
fn to_i64(&self) -> i64 {
39+
return field!((*self), value).with_mut(|__v| __v.prefix_inc().clone());
40+
}
41+
}
42+
pub fn __cpp2rust_init_globals() {}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
impl p1_template_constructor_from_own_type_Probe {
10+
pub unsafe fn new_1(u: *mut p1_template_constructor_from_own_type_Probe) -> Self {
11+
let mut this = Self {
12+
value: (((*u).value) + (1)),
13+
};
14+
this
15+
}
16+
}
17+
#[repr(C)]
18+
#[derive(Copy, Clone, VaArg, FnPtrArg, CppFromUnsafe, Default)]
19+
#[cpp_from(i32, new_2, value)]
20+
pub struct p1_template_constructor_from_own_type_Probe {
21+
pub value: i32,
22+
}
23+
impl p1_template_constructor_from_own_type_Probe {
24+
pub unsafe fn new_2(mut v: i32) -> Self {
25+
let mut this = Self { value: v };
26+
this
27+
}
28+
}
29+
pub unsafe fn test_0() {
30+
let mut probe: p1_template_constructor_from_own_type_Probe =
31+
p1_template_constructor_from_own_type_Probe::new_2({ 22 });
32+
let mut converted: p1_template_constructor_from_own_type_Probe =
33+
p1_template_constructor_from_own_type_Probe::new_1({ &mut probe });
34+
assert!(((converted.value) == (23)));
35+
}
36+
pub fn main() {
37+
unsafe {
38+
__cpp2rust_init_globals();
39+
std::process::exit(main_0() as i32);
40+
}
41+
}
42+
unsafe fn main_0() -> i32 {
43+
(unsafe { test_0() });
44+
return 0;
45+
}
46+
pub unsafe fn __cpp2rust_init_globals() {}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
#[repr(C)]
10+
#[derive(Copy, Clone, VaArg, FnPtrArg, CppFromUnsafe, Default)]
11+
#[cpp_into(i64, to_i64, mut_ptr)]
12+
pub struct p2_non_const_conversion_function_Gauge {
13+
pub value: i64,
14+
}
15+
impl p2_non_const_conversion_function_Gauge {
16+
pub unsafe fn to_i64(&mut self) -> i64 {
17+
return (*self.value.prefix_inc());
18+
}
19+
}
20+
pub unsafe fn test_0() {
21+
let mut gauge: p2_non_const_conversion_function_Gauge =
22+
p2_non_const_conversion_function_Gauge { value: 20_i64 };
23+
let mut converted: i64 =
24+
(unsafe { p2_non_const_conversion_function_Gauge::to_i64(&mut gauge) });
25+
assert!(((converted) == (21_i64)));
26+
assert!(((gauge.value) == (21_i64)));
27+
}
28+
pub fn main() {
29+
unsafe {
30+
__cpp2rust_init_globals();
31+
std::process::exit(main_0() as i32);
32+
}
33+
}
34+
unsafe fn main_0() -> i32 {
35+
(unsafe { test_0() });
36+
return 0;
37+
}
38+
pub unsafe fn __cpp2rust_init_globals() {}

0 commit comments

Comments
 (0)