Skip to content

Commit ac17fc0

Browse files
committed
Refined test to verify type of resulting integer
1 parent 8ea9451 commit ac17fc0

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

bindgen-integration/build.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,15 @@ impl ParseCallbacks for MacroCallback {
6060
}
6161
}
6262

63-
fn int_macro(&self, _name: &str, _value: i64) -> Option<IntKind> {
64-
Some(IntKind::Custom {
65-
name: "crate::MacroInteger",
66-
is_signed: true,
67-
})
63+
fn int_macro(&self, name: &str, _value: i64) -> Option<IntKind> {
64+
match name {
65+
"TESTMACRO_CUSTOMINTKIND_PATH" => Some(IntKind::Custom {
66+
name: "crate::MacroInteger",
67+
is_signed: true,
68+
}),
69+
70+
_ => None,
71+
}
6872
}
6973
}
7074

bindgen-integration/cpp/Test.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#define TESTMACRO_INTEGER 42
66
#define TESTMACRO_STRING "Hello Preprocessor!"
77
#define TESTMACRO_STRING_EXPANDED TESTMACRO_STRING
8+
#define TESTMACRO_CUSTOMINTKIND_PATH 123
89

910
#include <cwchar>
1011

bindgen-integration/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,3 +244,9 @@ fn test_item_rename() {
244244
member: bindings::bar { foo: 2 },
245245
};
246246
}
247+
248+
#[test]
249+
fn test_macro_customintkind_path() {
250+
let v: &std::any::Any = &bindings::TESTMACRO_CUSTOMINTKIND_PATH;
251+
assert!(v.is::<MacroInteger>())
252+
}

0 commit comments

Comments
 (0)