Skip to content

Commit 0a50db5

Browse files
committed
Add pre-commit tests
1 parent 7e67e00 commit 0a50db5

3 files changed

Lines changed: 52 additions & 0 deletions

File tree

‎tests/unit/compound_assign_ref.cpp‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright (c) 2022-present INESC-ID.
2+
// Distributed under the MIT license that can be found in the LICENSE file.
3+
4+
#include <cassert>
5+
#include <vector>
6+
7+
int main() {
8+
std::vector<int> v;
9+
v.push_back(10);
10+
v.front() += 5;
11+
assert(v.front() == 15);
12+
return v.front();
13+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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 fn main() {
10+
std::process::exit(main_0());
11+
}
12+
fn main_0() -> i32 {
13+
let v: Value<Vec<i32>> = Rc::new(RefCell::new(Vec::new()));
14+
(*v.borrow_mut()).push(10);
15+
let rhs_0 = ((((v.as_pointer() as Ptr<i32>).read()) as i32) + 5) as i32;
16+
(v.as_pointer() as Ptr<i32>).write(rhs_0);
17+
assert!((((v.as_pointer() as Ptr<i32>).read()) == 15));
18+
return ((v.as_pointer() as Ptr<i32>).read());
19+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
pub fn main() {
10+
unsafe {
11+
std::process::exit(main_0() as i32);
12+
}
13+
}
14+
unsafe fn main_0() -> i32 {
15+
let mut v: Vec<i32> = Vec::new();
16+
v.push(10);
17+
((v).first_mut().unwrap()) = ((((v).first_mut().unwrap()) as i32) + 5) as i32;
18+
assert!(((*((v).first_mut().unwrap())) == (15)));
19+
return (*((v).first_mut().unwrap()));
20+
}

0 commit comments

Comments
 (0)