Skip to content

Commit 660ba46

Browse files
committed
Fix NSDecimalNumber encoding test
1 parent 07f39cc commit 660ba46

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

crates/tests/src/array_ivars.rs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,24 @@ use objc2_foundation::{NSDecimalNumber, NSThread};
2525
#[cfg_attr(feature = "gnustep-1-7", ignore = "bitfields have types")]
2626
fn nsdecimal_ivar_encoding() {
2727
let cls = NSDecimalNumber::class();
28-
let expected = [
29-
("_exponent", EncodingBox::BitField(8, None)),
30-
("_length", EncodingBox::BitField(4, None)),
31-
("_isNegative", EncodingBox::BitField(1, None)),
32-
("_isCompact", EncodingBox::BitField(1, None)),
33-
("_reserved", EncodingBox::BitField(1, None)),
34-
("_hasExternalRefCount", EncodingBox::BitField(1, None)),
35-
("_refs", EncodingBox::BitField(16, None)),
36-
// Incomplete arrays -> pointer.
37-
(
38-
"_mantissa",
39-
EncodingBox::Pointer(Box::new(EncodingBox::UShort)),
40-
),
41-
];
28+
let expected = |last| {
29+
[
30+
("_exponent", EncodingBox::BitField(8, None)),
31+
("_length", EncodingBox::BitField(4, None)),
32+
("_isNegative", EncodingBox::BitField(1, None)),
33+
("_isCompact", EncodingBox::BitField(1, None)),
34+
("_reserved", EncodingBox::BitField(1, None)),
35+
("_hasExternalRefCount", EncodingBox::BitField(1, None)),
36+
("_refs", EncodingBox::BitField(16, None)),
37+
("_mantissa", last),
38+
]
39+
};
40+
41+
// Incomplete arrays -> pointer here on newer Foundation versions, but
42+
// -> zero-sized array on older versions.
43+
let expected1 = expected(EncodingBox::Pointer(Box::new(EncodingBox::UShort)));
44+
let expected2 = expected(EncodingBox::Pointer(Box::new(EncodingBox::UShort)));
45+
4246
let actual: Vec<_> = (*cls.instance_variables())
4347
.iter()
4448
.map(|ivar| {
@@ -48,7 +52,7 @@ fn nsdecimal_ivar_encoding() {
4852
)
4953
})
5054
.collect();
51-
assert_eq!(expected, *actual);
55+
assert!(expected1 == *actual || expected2 == *actual, "{actual:#?}");
5256
}
5357

5458
/// Defined in the header as:

0 commit comments

Comments
 (0)