Browse Source

Add a C++ test

add-rc-path
Alex Crichton 10 years ago
parent
commit
787d7710f8
  1. 10
      gcc-test/build.rs
  2. 9
      gcc-test/src/baz.cpp
  3. 2
      gcc-test/src/lib.rs
  4. 8
      gcc-test/tests/all.rs

10
gcc-test/build.rs

@ -13,11 +13,6 @@ fn main() {
.include("src/include")
.compile("libbar.a");
gcc::Config::new()
.file("src/bar1.c")
.file("src/bar2.c")
.compile("libbar.a");
let target = std::env::var("TARGET").unwrap();
let file = target.split("-").next().unwrap();
let file = format!("src/{}.{}", file,
@ -25,4 +20,9 @@ fn main() {
gcc::Config::new()
.file(file)
.compile("libasm.a");
gcc::Config::new()
.file("src/baz.cpp")
.cpp(true)
.compile("libbaz.a");
}

9
gcc-test/src/baz.cpp

@ -0,0 +1,9 @@
#include <stdint.h>
extern "C" int32_t
baz() {
int *a = new int(8);
int b = *a;
delete a;
return b;
}

2
gcc-test/src/lib.rs

@ -5,4 +5,6 @@ extern {
pub fn bar2() -> i32;
pub fn asm() -> i32;
pub fn baz() -> i32;
}

8
gcc-test/tests/all.rs

@ -17,10 +17,16 @@ fn bar_here() {
}
}
#[test]
fn asm_here() {
unsafe {
assert_eq!(asm(), 7);
}
}
#[test]
fn baz_here() {
unsafe {
assert_eq!(baz(), 8);
}
}

Loading…
Cancel
Save