diff options
Diffstat (limited to 'tests')
6 files changed, 166 insertions, 0 deletions
diff --git a/tests/expectations/tests/default-macro-constant-type-signed.rs b/tests/expectations/tests/default-macro-constant-type-signed.rs new file mode 100644 index 00000000..eda3117d --- /dev/null +++ b/tests/expectations/tests/default-macro-constant-type-signed.rs @@ -0,0 +1,42 @@ +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] + +pub const N0: i32 = 0; +pub const N1: i32 = 1; +pub const N2: i32 = 2; +pub const N_1: i32 = -1; +pub const N_2: i32 = -2; +pub const MAX_U32: i64 = 4294967295; +pub const MAX_I32: i32 = 2147483647; +pub const MAX_I32_Plus1: i64 = 2147483648; +pub const MAX_U32_Plus1: i64 = 4294967296; +pub const MAX_I32_Minus1: i32 = 2147483646; +pub const MAX_U32_Minus1: i64 = 4294967294; +pub const MIN_U32: i32 = 0; +pub const MIN_I32: i32 = -2147483648; +pub const MIN_U32_Plus1: i32 = 1; +pub const MIN_I32_Plus1: i32 = -2147483647; +pub const MIN_U32_Minus1: i32 = -1; +pub const MIN_I32_Minus1: i64 = -2147483649; +pub const LONG12: i64 = 123456789012; +pub const LONG_12: i64 = -123456789012; +extern "C" { + pub fn foo( + arg1: ::std::os::raw::c_int, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_uint, + arg4: ::std::os::raw::c_char, + arg5: ::std::os::raw::c_uchar, + arg6: ::std::os::raw::c_schar, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn bar( + arg1: ::std::os::raw::c_long, + arg2: ::std::os::raw::c_longlong, + ) -> ::std::os::raw::c_long; +} diff --git a/tests/expectations/tests/default-macro-constant-type-unsigned.rs b/tests/expectations/tests/default-macro-constant-type-unsigned.rs new file mode 100644 index 00000000..241443aa --- /dev/null +++ b/tests/expectations/tests/default-macro-constant-type-unsigned.rs @@ -0,0 +1,42 @@ +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] + +pub const N0: u32 = 0; +pub const N1: u32 = 1; +pub const N2: u32 = 2; +pub const N_1: i32 = -1; +pub const N_2: i32 = -2; +pub const MAX_U32: u32 = 4294967295; +pub const MAX_I32: u32 = 2147483647; +pub const MAX_I32_Plus1: u32 = 2147483648; +pub const MAX_U32_Plus1: u64 = 4294967296; +pub const MAX_I32_Minus1: u32 = 2147483646; +pub const MAX_U32_Minus1: u32 = 4294967294; +pub const MIN_U32: u32 = 0; +pub const MIN_I32: i32 = -2147483648; +pub const MIN_U32_Plus1: u32 = 1; +pub const MIN_I32_Plus1: i32 = -2147483647; +pub const MIN_U32_Minus1: i32 = -1; +pub const MIN_I32_Minus1: i64 = -2147483649; +pub const LONG12: u64 = 123456789012; +pub const LONG_12: i64 = -123456789012; +extern "C" { + pub fn foo( + arg1: ::std::os::raw::c_int, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_uint, + arg4: ::std::os::raw::c_char, + arg5: ::std::os::raw::c_uchar, + arg6: ::std::os::raw::c_schar, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn bar( + arg1: ::std::os::raw::c_long, + arg2: ::std::os::raw::c_longlong, + ) -> ::std::os::raw::c_long; +} diff --git a/tests/expectations/tests/default-macro-constant-type.rs b/tests/expectations/tests/default-macro-constant-type.rs new file mode 100644 index 00000000..241443aa --- /dev/null +++ b/tests/expectations/tests/default-macro-constant-type.rs @@ -0,0 +1,42 @@ +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] + +pub const N0: u32 = 0; +pub const N1: u32 = 1; +pub const N2: u32 = 2; +pub const N_1: i32 = -1; +pub const N_2: i32 = -2; +pub const MAX_U32: u32 = 4294967295; +pub const MAX_I32: u32 = 2147483647; +pub const MAX_I32_Plus1: u32 = 2147483648; +pub const MAX_U32_Plus1: u64 = 4294967296; +pub const MAX_I32_Minus1: u32 = 2147483646; +pub const MAX_U32_Minus1: u32 = 4294967294; +pub const MIN_U32: u32 = 0; +pub const MIN_I32: i32 = -2147483648; +pub const MIN_U32_Plus1: u32 = 1; +pub const MIN_I32_Plus1: i32 = -2147483647; +pub const MIN_U32_Minus1: i32 = -1; +pub const MIN_I32_Minus1: i64 = -2147483649; +pub const LONG12: u64 = 123456789012; +pub const LONG_12: i64 = -123456789012; +extern "C" { + pub fn foo( + arg1: ::std::os::raw::c_int, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_uint, + arg4: ::std::os::raw::c_char, + arg5: ::std::os::raw::c_uchar, + arg6: ::std::os::raw::c_schar, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn bar( + arg1: ::std::os::raw::c_long, + arg2: ::std::os::raw::c_longlong, + ) -> ::std::os::raw::c_long; +} diff --git a/tests/headers/default-macro-constant-type-signed.h b/tests/headers/default-macro-constant-type-signed.h new file mode 100644 index 00000000..da3f1344 --- /dev/null +++ b/tests/headers/default-macro-constant-type-signed.h @@ -0,0 +1,3 @@ +// bindgen-flags: --default-macro-constant-type signed +// All values are i32 if they fit; otherwise i64. +#include "default-macro-constant-type.h" diff --git a/tests/headers/default-macro-constant-type-unsigned.h b/tests/headers/default-macro-constant-type-unsigned.h new file mode 100644 index 00000000..1078e852 --- /dev/null +++ b/tests/headers/default-macro-constant-type-unsigned.h @@ -0,0 +1,3 @@ +// bindgen-flags: --default-macro-constant-type unsigned +// Negative values are i32 or i64; others are u32 or u64. +#include "default-macro-constant-type.h" diff --git a/tests/headers/default-macro-constant-type.h b/tests/headers/default-macro-constant-type.h new file mode 100644 index 00000000..d11941b4 --- /dev/null +++ b/tests/headers/default-macro-constant-type.h @@ -0,0 +1,34 @@ +// Test default of --default-macro-constant-type +// Negative values are i32 or i64; others are u32 or u64. + +#define N0 0 +#define N1 1ULL +#define N2 2ULL + +#define N_1 (-1LL) +#define N_2 (-2LL) + +#define MAX_U32 0xFFFFFFFFULL +#define MAX_I32 (0x80000000ULL - 1) + +#define MAX_I32_Plus1 (MAX_I32 + 1) +#define MAX_U32_Plus1 (MAX_U32 + 1) + +#define MAX_I32_Minus1 (MAX_I32 - 1) +#define MAX_U32_Minus1 (MAX_U32 - 1) + +#define MIN_U32 0 +#define MIN_I32 (- (1ULL<<31)) + +#define MIN_U32_Plus1 (MIN_U32 + 1) +#define MIN_I32_Plus1 (MIN_I32 + 1) + +#define MIN_U32_Minus1 (MIN_U32 - 1) +#define MIN_I32_Minus1 (MIN_I32 - 1) + +#define LONG12 123456789012ULL +#define LONG_12 (- 123456789012ULL) + +// Function parameter and return types are not affected. +int foo(int, signed, unsigned, char, unsigned char, signed char); +long bar(long, long long); |