summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bindgen-integration/cpp/Test.cc7
-rw-r--r--bindgen-integration/cpp/Test.h4
-rw-r--r--bindgen-integration/src/lib.rs23
3 files changed, 34 insertions, 0 deletions
diff --git a/bindgen-integration/cpp/Test.cc b/bindgen-integration/cpp/Test.cc
index d9c13a76..fa0ff827 100644
--- a/bindgen-integration/cpp/Test.cc
+++ b/bindgen-integration/cpp/Test.cc
@@ -1,5 +1,12 @@
#include "Test.h"
+const int Test::COUNTDOWN[] = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
+const int* Test::COUNTDOWN_PTR = Test::COUNTDOWN;
+
+const int* Test::countdown() {
+ return COUNTDOWN;
+}
+
const char* Test::name() {
return "Test";
}
diff --git a/bindgen-integration/cpp/Test.h b/bindgen-integration/cpp/Test.h
index f1e38c40..db90f4d7 100644
--- a/bindgen-integration/cpp/Test.h
+++ b/bindgen-integration/cpp/Test.h
@@ -7,6 +7,10 @@ public:
static const char* name();
Test(int foo);
Test(double foo);
+
+ static const int COUNTDOWN[];
+ static const int* COUNTDOWN_PTR;
+ static const int* countdown();
};
namespace testing {
diff --git a/bindgen-integration/src/lib.rs b/bindgen-integration/src/lib.rs
index 5c4b4308..c64589a8 100644
--- a/bindgen-integration/src/lib.rs
+++ b/bindgen-integration/src/lib.rs
@@ -3,6 +3,29 @@ mod bindings {
}
use std::ffi::CStr;
+use std::os::raw::c_int;
+
+#[test]
+fn test_static_array() {
+ let mut test = unsafe { bindings::Test_COUNTDOWN.as_ptr() };
+ let expected = unsafe { bindings::Test_countdown()};
+ let also_expected = unsafe { bindings::Test_COUNTDOWN_PTR };
+ assert!(!test.is_null());
+ assert_eq!(also_expected, expected);
+ assert_eq!(test, also_expected);
+
+ let mut expected = 10;
+ unsafe {
+ loop {
+ assert_eq!(*test, expected);
+ if *test == 0 {
+ break;
+ }
+ test = test.offset(1);
+ expected -= 1;
+ }
+ }
+}
#[test]
fn test_static_method() {