STAssertEquals: null pointer and NULL gives type mismatch error

139 Views Asked by At

What is wrong, here I am doing?

ptr == NULL is true,

This is also ok,

STAssertTrue(ptr == NULL, @"ptr is null"); //succeeded

But,

STAssertEquals(ptr, NULL, @"");

is giving error, "Type mismatch --- ".

- (void) testNilEncoding {
    NSString * nils = nil;
    const char * ptr = [nils dataUsingEncoding:NSUTF8StringEncoding].bytes;
    const char * ptr2 = [nils cStringUsingEncoding:NSUTF8StringEncoding];

    if (ptr == NULL) {
        NSLog(@"Ptr is null"); // ok
    }
    STAssertTrue(ptr == NULL, @"ptr is null"); //ok
    STAssertEquals(ptr, NULL, @""); //fails
    STAssertEquals(ptr2, NULL, @""); //fails
}
0

There are 0 best solutions below