Add test suite beyond the existing demo

This commit is contained in:
David Tolnay 2020-01-25 16:49:00 -08:00
parent 54a53df768
commit 97c7210039
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
6 changed files with 46 additions and 2 deletions

View File

@ -29,8 +29,9 @@ thiserror = "1.0"
cc = "1.0.49"
[dev-dependencies]
cxx-test-suite = { version = "0", path = "tests/ffi" }
rustversion = "1.0"
trybuild = "1.0"
trybuild = "1.0.21"
[workspace]
members = ["cmd", "demo-rs", "macro"]
members = ["cmd", "demo-rs", "macro", "tests/ffi"]

14
tests/ffi/Cargo.toml Normal file
View File

@ -0,0 +1,14 @@
[package]
name = "cxx-test-suite"
version = "0.0.0"
edition = "2018"
publish = false
[lib]
path = "lib.rs"
[dependencies]
cxx = { path = "../.." }
[build-dependencies]
cxx = { path = "../.." }

11
tests/ffi/build.rs Normal file
View File

@ -0,0 +1,11 @@
fn main() {
if cfg!(trybuild) {
return;
}
cxx::Build::new()
.bridge("lib.rs")
.file("tests.cc")
.flag("-std=c++11")
.compile("cxx-test-suite");
}

6
tests/ffi/lib.rs Normal file
View File

@ -0,0 +1,6 @@
#[cxx::bridge(namespace = tests)]
pub mod ffi {
extern "C" {
include!("tests/ffi/tests.h");
}
}

6
tests/ffi/tests.cc Normal file
View File

@ -0,0 +1,6 @@
#include "tests/ffi/lib.rs"
#include "tests/ffi/tests.h"
namespace tests {
} // namespace tests

6
tests/ffi/tests.h Normal file
View File

@ -0,0 +1,6 @@
#pragma once
#include "include/cxxbridge.h"
namespace tests {
} // namespace tests