diff options
-rw-r--r-- | bindgen-integration/build.rs | 11 | ||||
-rwxr-xr-x | bindgen-integration/src/lib.rs | 9 |
2 files changed, 20 insertions, 0 deletions
diff --git a/bindgen-integration/build.rs b/bindgen-integration/build.rs index b28dcee5..fa0246c4 100644 --- a/bindgen-integration/build.rs +++ b/bindgen-integration/build.rs @@ -119,6 +119,17 @@ impl ParseCallbacks for MacroCallback { } } } + + // Test the "custom derives" capability by adding `PartialEq` to the `Test` struct. + fn add_derives(&self, name: &str) -> Vec<String> { + if name == "Test" { + vec![ + "PartialEq".into(), + ] + } else { + vec![] + } + } } impl Drop for MacroCallback { diff --git a/bindgen-integration/src/lib.rs b/bindgen-integration/src/lib.rs index 4b288afd..f56e7259 100755 --- a/bindgen-integration/src/lib.rs +++ b/bindgen-integration/src/lib.rs @@ -267,3 +267,12 @@ fn test_homogeneous_aggregate_float_union() { assert_eq!([1., 2., 3., 4.], coord.v) } } + +#[test] +fn test_custom_derive() { + // The `add_derives` callback should have added `#[derive(PartialEq)]` + // to the `Test` struct. If it didn't, this will fail to compile. + let test1 = unsafe { bindings::Test::new(5) }; + let test2 = unsafe { bindings::Test::new(6) }; + assert_ne!(test1, test2); +} |