karim
karim

Reputation: 15589

STAssertEquals: null pointer and NULL gives type mismatch error

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
}

Upvotes: 0

Views: 126

Answers (0)

Related Questions