mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-01-12 22:51:50 +08:00
Add assertions to RKMIMETypeSerialization and RKTestFixture
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user