summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2017-05-21 18:19:41 +0200
committerEmilio Cobos Álvarez <emilio@crisal.io>2017-05-21 18:19:41 +0200
commit62463b1912fbb5d2741dd7c8d18ba80c25d32dfd (patch)
treed9a5c47a6789ac84cf44a02bd5c5d37c7b59f2a8
parent9bb794bb3305ae2355e1945b3abe3d0d8064a428 (diff)
Add a test for short enums.
Closes #711.
-rw-r--r--tests/expectations/tests/short-enums.rs15
-rw-r--r--tests/headers/short-enums.hpp19
2 files changed, 34 insertions, 0 deletions
diff --git a/tests/expectations/tests/short-enums.rs b/tests/expectations/tests/short-enums.rs
new file mode 100644
index 00000000..55bf2105
--- /dev/null
+++ b/tests/expectations/tests/short-enums.rs
@@ -0,0 +1,15 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(u8)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum one_byte_t { SOME_VALUE = 1, }
+#[repr(u16)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum two_byte_t { SOME_OTHER_VALUE = 256, }
+#[repr(u32)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum four_byte_t { SOME_BIGGER_VALUE = 16777216, }
diff --git a/tests/headers/short-enums.hpp b/tests/headers/short-enums.hpp
new file mode 100644
index 00000000..484c84af
--- /dev/null
+++ b/tests/headers/short-enums.hpp
@@ -0,0 +1,19 @@
+// bindgen-flags: -- -std=c++11 -fshort-enums
+
+typedef enum {
+ SOME_VALUE = 0x1,
+} one_byte_t;
+
+static_assert(sizeof(one_byte_t) == 1, "Short enums should work");
+
+typedef enum {
+ SOME_OTHER_VALUE = 0x100,
+} two_byte_t;
+
+static_assert(sizeof(two_byte_t) == 2, "");
+
+typedef enum {
+ SOME_BIGGER_VALUE = 0x1000000,
+} four_byte_t;
+
+static_assert(sizeof(four_byte_t) == 4, "");