Skip to content

Commit cfcbbd5

Browse files
committed
Fix test_retain_autoreleased on GNUStep
1 parent 1d1ced6 commit cfcbbd5

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

objc2-foundation/tests/objc_id_retain_autoreleased.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,22 @@ fn test_retain_autoreleased() {
3434
let data = create_data(b"12");
3535
// The autorelease-return-mechanism has to "warm up" somehow? At least
3636
// for some reason the first time this is used it fails.
37-
assert_eq!(retain_count(&data), 2);
37+
assert_eq!(retain_count(&data), if cfg!(gnustep) { 1 } else { 2 });
3838

3939
// When compiled in release mode / with optimizations enabled,
4040
// subsequent usage of `retain_autoreleased` will succeed in retaining
4141
// the autoreleased value!
42-
let expected_retain_count = if cfg!(debug_assertions) { 2 } else { 1 };
42+
let expected = if cfg!(all(debug_assertions, not(gnustep))) {
43+
2
44+
} else {
45+
1
46+
};
4347

4448
let data = create_data(b"34");
45-
assert_eq!(retain_count(&data), expected_retain_count);
49+
assert_eq!(retain_count(&data), expected);
4650

4751
let data = create_data(b"56");
48-
assert_eq!(retain_count(&data), expected_retain_count);
52+
assert_eq!(retain_count(&data), expected);
4953

5054
// Here we manually clean up the autorelease, so it will always be 1.
5155
let data = autoreleasepool(|_| create_data(b"78"));

0 commit comments

Comments
 (0)