Add assertions to RKMIMETypeSerialization and RKTestFixture

This commit is contained in:
Blake Watters
2013-03-14 11:49:22 -04:00
parent 10ad79a352
commit 8ff6f62297
2 changed files with 8 additions and 5 deletions

View File

@@ -146,6 +146,9 @@
+ (id)objectFromData:(NSData *)data MIMEType:(NSString *)MIMEType error:(NSError **)error
{
NSParameterAssert(data);
NSParameterAssert(MIMEType);
Class<RKSerialization> serializationClass = [self serializationClassForMIMEType:MIMEType];
if (!serializationClass) {
if (error) {
@@ -161,6 +164,8 @@
+ (id)dataFromObject:(id)object MIMEType:(NSString *)MIMEType error:(NSError **)error
{
NSParameterAssert(object);
NSParameterAssert(MIMEType);
Class<RKSerialization> serializationClass = [self serializationClassForMIMEType:MIMEType];
if (!serializationClass) {
if (error) {

View File

@@ -86,14 +86,12 @@ static NSBundle *fixtureBundle = nil;
{
NSError *error = nil;
NSData *resourceContents = [self dataWithContentsOfFixture:fixtureName];
NSAssert(resourceContents, @"Failed to read fixture named '%@'", fixtureName);
NSString *MIMEType = [self MIMETypeForFixture:fixtureName];
NSAssert(MIMEType, @"Failed to determine MIME type of fixture named '%@'", fixtureName);
id object = [RKMIMETypeSerialization objectFromData:resourceContents MIMEType:MIMEType error:&error];
if (object == nil) {
RKLogCritical(@"Failed to parse fixture name '%@' in bundle %@. Error: %@", fixtureName, [self fixtureBundle], [error localizedDescription]);
return nil;
}
NSAssert(object, @"Failed to parse fixture name '%@' in bundle %@. Error: %@", fixtureName, [self fixtureBundle], [error localizedDescription]);
return object;
}