Add integration test for name matching

This commit is contained in:
Youmu
2020-09-14 16:04:34 -04:00
committed by Emilio Cobos Álvarez
parent 12b5eac561
commit 4656d34773
4 changed files with 31 additions and 4 deletions
+7 -3
View File
@@ -1,8 +1,8 @@
extern crate bindgen;
extern crate cc;
use bindgen::callbacks::{MacroParsingBehavior, ParseCallbacks, IntKind};
use bindgen::Builder;
use bindgen::callbacks::{IntKind, MacroParsingBehavior, ParseCallbacks};
use bindgen::{Builder, EnumVariation};
use std::collections::HashSet;
use std::env;
use std::path::PathBuf;
@@ -147,7 +147,9 @@ fn main() {
let bindings = Builder::default()
.rustfmt_bindings(false)
.enable_cxx_namespaces()
.rustified_enum(".*")
.default_enum_style(EnumVariation::Rust {
non_exhaustive: false,
})
.raw_line("pub use self::root::*;")
.raw_line("extern { fn my_prefixed_function_to_remove(i: i32); }")
.module_raw_line("root::testing", "pub type Bar = i32;")
@@ -159,6 +161,8 @@ fn main() {
seen_funcs: Mutex::new(0),
}))
.blacklist_function("my_prefixed_function_to_remove")
.constified_enum("my_prefixed_enum_to_be_constified")
.opaque_type("my_prefixed_templated_foo<my_prefixed_baz>")
.generate()
.expect("Unable to generate bindings");
+1 -1
View File
@@ -134,4 +134,4 @@ Seventh::assert(bool first,
int my_prefixed_function_name() {
return 4;
}
}
+17
View File
@@ -210,4 +210,21 @@ struct my_prefixed_foo {
my_prefixed_bar member;
};
enum my_prefixed_enum_to_be_constified {
ONE = 1,
TWO,
THREE,
};
struct my_prefixed_baz {
char foo[30];
};
template<typename T>
struct my_prefixed_templated_foo {
T member;
};
my_prefixed_templated_foo<my_prefixed_baz> TEMPLATED_CONST_VALUE;
void my_prefixed_function_to_remove();
+6
View File
@@ -245,6 +245,12 @@ fn test_item_rename() {
};
}
#[test]
fn test_matching_with_rename() {
assert_eq!(bindings::enum_to_be_constified_THREE, 3);
assert_eq!(unsafe { bindings::TEMPLATED_CONST_VALUE.len() }, 30);
}
#[test]
fn test_macro_customintkind_path() {
let v: &std::any::Any = &bindings::TESTMACRO_CUSTOMINTKIND_PATH;