summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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, "");