Add test to ensure that NSData assigns bytes and length

Specifically on initWithBytesNoCopy:length:deallocator:
This commit is contained in:
Mads Marquart 2021-10-29 10:17:39 +02:00
parent d439847ba6
commit 9684c9fda1

View file

@ -89,6 +89,8 @@ int main()
deallocator: ^(void* bytes, NSUInteger length) {
called++;
}];
PASS([immutable length] == 4, "Length set");
PASS([immutable bytes] == stackBuf, "Bytes set");
PASS_RUNS([immutable release]; immutable = nil;,
"No free() error with custom deallocator");
PASS(called == 1, "Deallocator block called");
@ -102,6 +104,8 @@ int main()
called++;
}
];
PASS([mutable length] == 4, "Length set");
PASS([mutable bytes] == buf, "Bytes set");
PASS_RUNS([mutable release]; mutable = nil;,
"No free() error with custom deallocator on mutable data");
PASS(called == 2, "Deallocator block called on -dealloc of mutable data");