erikdoe / ocmock

Mock objects for Objective-C
http://ocmock.org
Apache License 2.0
2.16k stars 606 forks source link

OCMVerify with CMTime argument fails on m1 mac. #526

Open bheinzelman opened 2 years ago

bheinzelman commented 2 years ago

I have several tests in my codebase that use OCMVerify to verify that methods were called that take CMTime as arguments. This seems to work on Intel mac, but not m1. Here is minimal example of a test that does not work:

@interface TestClassB: NSObject

- (void)printCMTime:(CMTime)time;

@end

@implementation TestClassB

- (void)printCMTime:(CMTime)time {
    NSLog(@"Time = %.2f", CMTimeGetSeconds(time));
}

@end

@interface TestClass: NSObject

@property (nonatomic) TestClassB *b;

- (void)someFuncThatTakesCMTime:(CMTime)time;

@end

@implementation TestClass

- (instancetype)init {
    self = [super init];
    _b = [[TestClassB alloc] init];
    return self;
}

- (void)someFuncThatTakesCMTime:(CMTime)time {
    [_b printCMTime:time];
}

@end

@interface CMTimeTest : XCTestCase
@end

@implementation CMTimeTest

- (void)testCMTime {
    id mockB = OCMClassMock(TestClassB.class);

    TestClass *t = [[TestClass alloc] init];
    t.b = mockB;

    [t someFuncThatTakesCMTime:kCMTimeZero];

    OCMVerify([mockB printCMTime:kCMTimeZero]);
}

@end
erikdoe commented 2 years ago

Thank you for reporting this problem and for including a failing test. Unfortunately, I currently don't have access to a Mac with an M1 processor, which means I can't reproduce the problem. Can you describe what happens when you run this on an M1 Mac?

bheinzelman commented 2 years ago

Hello @erikdoe, it fails with the following error: : error: -[CMTimeTest testCMTime] : OCClassMockObject(TestClassB): Method printCMTime:({length = 24, bytes = 0x000000000000000001000000010000000000000000000000}) was not invoked; but was expected at least once. On this line: OCMVerify([mockB printCMTime:kCMTimeZero]);