summaryrefslogtreecommitdiff
path: root/bindgen-integration/src
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2016-12-12 16:11:43 +0100
committerEmilio Cobos Álvarez <emilio@crisal.io>2016-12-13 14:33:01 +0100
commit883ff74e5f20b68b41f322daa582d9208eece65a (patch)
tree10f0c8aa40dad4a9b48d8a705761074fff9036d3 /bindgen-integration/src
parent5d9c48e59b49135db1ecfd4ff8c3dbab8ed05086 (diff)
Add support for constructors, and integration tests.
Diffstat (limited to 'bindgen-integration/src')
-rw-r--r--bindgen-integration/src/lib.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/bindgen-integration/src/lib.rs b/bindgen-integration/src/lib.rs
new file mode 100644
index 00000000..4f239510
--- /dev/null
+++ b/bindgen-integration/src/lib.rs
@@ -0,0 +1,28 @@
+mod bindings {
+ include!(concat!(env!("OUT_DIR"), "/test.rs"));
+}
+
+use std::ffi::CStr;
+
+#[test]
+fn test_static_method() {
+ let c_str = unsafe { bindings::Test::name() };
+ let name = unsafe {
+ CStr::from_ptr(c_str).to_string_lossy().into_owned()
+ };
+ assert_eq!(name, "Test", "Calling a static C++ method works!");
+}
+
+#[test]
+fn test_constructor() {
+ let test = unsafe { bindings::Test::new(5) };
+ assert_eq!(test.m_int, 5);
+ assert_eq!(test.m_double, 0.0);
+}
+
+#[test]
+fn test_overload() {
+ let test = unsafe { bindings::Test::new1(5.0) };
+ assert_eq!(test.m_int, 0);
+ assert_eq!(test.m_double, 5.0);
+}