Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Commit

Permalink
Merge branch 'release/1.4.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
vilanovi committed Dec 11, 2015
2 parents 8f49e97 + 67b7761 commit 045df90
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 1 deletion.
6 changes: 5 additions & 1 deletion NSObject+Motis.m
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,11 @@ - (BOOL)mts_validateAutomaticallyValue:(inout __autoreleasing id *)ioValue toCla
*ioValue = [NSMutableArray arrayWithArray:*ioValue];
return *ioValue != nil;
}
else if ([typeClass isSubclassOfClass:NSArray.class])
{
*ioValue = [NSArray arrayWithArray:*ioValue];
return *ioValue != nil;
}
else if ([typeClass isSubclassOfClass:NSMutableSet.class])
{
*ioValue = [NSMutableSet setWithArray:*ioValue];
Expand All @@ -1154,7 +1159,6 @@ - (BOOL)mts_validateAutomaticallyValue:(inout __autoreleasing id *)ioValue toCla
*ioValue = [NSOrderedSet orderedSetWithArray:*ioValue];
return *ioValue != nil;
}
return *ioValue != nil;
}
else if ([*ioValue isKindOfClass:NSDictionary.class]) // <-- DICTIONARIES
{
Expand Down
55 changes: 55 additions & 0 deletions SampleProject/Motis Tests/MJValidationTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,61 @@ - (void)testArrayToDateArray
XCTAssertEqual(array.count, object.datesArray.count, @"Date array conversion failed");
}

- (void)testMutableArray
{
MJTestMotisMappingObject *object = [MJTestMotisMappingObject new];

NSArray *array = @[@1, @"string"];
[object mts_setValue:array forKey:@"mutable_array"];

XCTAssert([object.mutableArray isKindOfClass:NSMutableArray.class], @"Failed to create mutable array");
XCTAssertEqualObjects(array, object.mutableArray, @"Failed to map mutable array %@", array.description);
}

- (void)testSet
{
MJTestMotisMappingObject *object = [MJTestMotisMappingObject new];

NSArray *array = @[@1, @"string"];
[object mts_setValue:array forKey:@"set"];

XCTAssert([object.set isKindOfClass:NSSet.class], @"Failed to create set");
XCTAssertEqualObjects([NSSet setWithArray:array], object.set, @"Failed to map set %@", array.description);
}

- (void)testMutableSet
{
MJTestMotisMappingObject *object = [MJTestMotisMappingObject new];

NSArray *array = @[@1, @"string"];
[object mts_setValue:array forKey:@"mutable_set"];

XCTAssert([object.mutableSet isKindOfClass:NSMutableSet.class], @"Failed to create mutable set");
XCTAssertEqualObjects([NSSet setWithArray:array], object.mutableSet, @"Failed to map mutable set %@", array.description);
}

- (void)testOrderedSet
{
MJTestMotisMappingObject *object = [MJTestMotisMappingObject new];

NSArray *array = @[@1, @"string"];
[object mts_setValue:array forKey:@"ordered_set"];

XCTAssert([object.orderedSet isKindOfClass:NSOrderedSet.class], @"Failed to create ordered set");
XCTAssertEqualObjects([NSOrderedSet orderedSetWithArray:array], object.orderedSet, @"Failed to map ordered set %@", array.description);
}

- (void)testMutableOrderedSet
{
MJTestMotisMappingObject *object = [MJTestMotisMappingObject new];

NSArray *array = @[@1, @"string"];
[object mts_setValue:array forKey:@"mutable_ordered_set"];

XCTAssert([object.mutableOrderedSet isKindOfClass:NSMutableOrderedSet.class], @"Failed to create mutable ordered set");
XCTAssertEqualObjects([NSMutableOrderedSet orderedSetWithArray:array], object.mutableOrderedSet, @"Failed to map mutable ordered set %@", array.description);
}

#pragma mark - UNDEFINED MAPPINGS

// ------------------------------------------------------------------------------------------------------------------------ //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ + (NSDictionary*)mts_mapping
@"url_array": mts_key(urlsArray),
@"date_array": mts_key(datesArray),

@"mutable_array": mts_key(mutableArray),
@"set": mts_key(set),
@"mutable_set": mts_key(mutableSet),
@"ordered_set": mts_key(orderedSet),
@"mutable_ordered_set": mts_key(mutableOrderedSet),

@"unsigned_enum": mts_key(unsignedEnum),
@"signed_enum": mts_key(signedEnum),

Expand Down
6 changes: 6 additions & 0 deletions SampleProject/Motis Tests/Validation Test/MJTestObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ typedef NS_ENUM(NSInteger, MJSignedEnum)
@property (nonatomic, strong) NSArray *urlsArray;
@property (nonatomic, strong) NSArray *datesArray;

@property (nonatomic, strong) NSMutableArray *mutableArray;
@property (nonatomic, strong) NSSet *set;
@property (nonatomic, strong) NSMutableSet *mutableSet;
@property (nonatomic, strong) NSOrderedSet *orderedSet;
@property (nonatomic, strong) NSMutableOrderedSet *mutableOrderedSet;

@property (nonatomic, assign) MJUnsignedEnum unsignedEnum;
@property (nonatomic, assign) MJSignedEnum signedEnum;

Expand Down

0 comments on commit 045df90

Please sign in to comment.