Skip to content

Commit befc118

Browse files
committed
Fix encode tests on macOS 32bit
1 parent 3181624 commit befc118

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

tests/src/test_encode_utils.rs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ unsafe fn assert_str<T: Display>(s: *const c_char, expected: T) {
2626
}
2727

2828
macro_rules! assert_inner {
29-
(enc $stat:ident => $expected:expr) => {
29+
(enc $(#[$m:meta])* $stat:ident => $expected:expr) => {
30+
$(#[$m])*
3031
#[test]
3132
fn $stat() {
3233
extern "C" {
@@ -35,7 +36,8 @@ macro_rules! assert_inner {
3536
unsafe { assert_encoding($stat, $expected) };
3637
}
3738
};
38-
(str $stat:ident => $expected:expr) => {
39+
(str $(#[$m:meta])* $stat:ident => $expected:expr) => {
40+
$(#[$m])*
3941
#[test]
4042
fn $stat() {
4143
extern "C" {
@@ -47,11 +49,14 @@ macro_rules! assert_inner {
4749
}
4850

4951
macro_rules! assert_types {
50-
($($stat:ident => $type:ty,)+) => {$(
52+
($(
53+
$(#[$m:meta])*
54+
$stat:ident => $type:ty,
55+
)+) => {$(
5156
paste! {
52-
assert_inner!(enc [<ENCODING_ $stat>] => <$type>::ENCODING);
53-
assert_inner!(enc [<ENCODING_ $stat _POINTER>] => <*const $type>::ENCODING);
54-
assert_inner!(str [<ENCODING_ $stat _ATOMIC>] => format!("A{}", <$type>::ENCODING));
57+
assert_inner!(enc $(#[$m])* [<ENCODING_ $stat>] => <$type>::ENCODING);
58+
assert_inner!(enc $(#[$m])* [<ENCODING_ $stat _POINTER>] => <*const $type>::ENCODING);
59+
assert_inner!(str $(#[$m])* [<ENCODING_ $stat _ATOMIC>] => format!("A{}", <$type>::ENCODING));
5560
}
5661
)+};
5762
}
@@ -111,15 +116,24 @@ assert_types! {
111116
INT16 => i16,
112117
INT32 => i32,
113118
INT64 => i64,
114-
INTPTR => isize,
115119
UINT8 => u8,
116120
UINT16 => u16,
117121
UINT32 => u32,
118122
UINT64 => u64,
123+
124+
// `intptr`, `uintptr` and `size_t` are cfg-guarded because they are
125+
// simply just too much of a hassle to get working on this old platform.
126+
//
127+
// Pointers (`intptr*`) works, but not plain `intptr`...
128+
129+
#[cfg(not(all(target_os = "macos", target_arch = "x86")))]
130+
INTPTR => isize,
131+
#[cfg(not(all(target_os = "macos", target_arch = "x86")))]
119132
UINTPTR => usize,
120133

121134
// stddef.h
122135

136+
#[cfg(not(all(target_os = "macos", target_arch = "x86")))]
123137
SIZE_T => usize,
124138
PTRDIFF_T => isize,
125139

0 commit comments

Comments
 (0)