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

Commit 045df90

Browse files
committed
Merge branch 'release/1.4.3'
2 parents 8f49e97 + 67b7761 commit 045df90

File tree

4 files changed

+72
-1
lines changed

4 files changed

+72
-1
lines changed

NSObject+Motis.m

+5-1
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,11 @@ - (BOOL)mts_validateAutomaticallyValue:(inout __autoreleasing id *)ioValue toCla
11341134
*ioValue = [NSMutableArray arrayWithArray:*ioValue];
11351135
return *ioValue != nil;
11361136
}
1137+
else if ([typeClass isSubclassOfClass:NSArray.class])
1138+
{
1139+
*ioValue = [NSArray arrayWithArray:*ioValue];
1140+
return *ioValue != nil;
1141+
}
11371142
else if ([typeClass isSubclassOfClass:NSMutableSet.class])
11381143
{
11391144
*ioValue = [NSMutableSet setWithArray:*ioValue];
@@ -1154,7 +1159,6 @@ - (BOOL)mts_validateAutomaticallyValue:(inout __autoreleasing id *)ioValue toCla
11541159
*ioValue = [NSOrderedSet orderedSetWithArray:*ioValue];
11551160
return *ioValue != nil;
11561161
}
1157-
return *ioValue != nil;
11581162
}
11591163
else if ([*ioValue isKindOfClass:NSDictionary.class]) // <-- DICTIONARIES
11601164
{

SampleProject/Motis Tests/MJValidationTest.m

+55
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,61 @@ - (void)testArrayToDateArray
629629
XCTAssertEqual(array.count, object.datesArray.count, @"Date array conversion failed");
630630
}
631631

632+
- (void)testMutableArray
633+
{
634+
MJTestMotisMappingObject *object = [MJTestMotisMappingObject new];
635+
636+
NSArray *array = @[@1, @"string"];
637+
[object mts_setValue:array forKey:@"mutable_array"];
638+
639+
XCTAssert([object.mutableArray isKindOfClass:NSMutableArray.class], @"Failed to create mutable array");
640+
XCTAssertEqualObjects(array, object.mutableArray, @"Failed to map mutable array %@", array.description);
641+
}
642+
643+
- (void)testSet
644+
{
645+
MJTestMotisMappingObject *object = [MJTestMotisMappingObject new];
646+
647+
NSArray *array = @[@1, @"string"];
648+
[object mts_setValue:array forKey:@"set"];
649+
650+
XCTAssert([object.set isKindOfClass:NSSet.class], @"Failed to create set");
651+
XCTAssertEqualObjects([NSSet setWithArray:array], object.set, @"Failed to map set %@", array.description);
652+
}
653+
654+
- (void)testMutableSet
655+
{
656+
MJTestMotisMappingObject *object = [MJTestMotisMappingObject new];
657+
658+
NSArray *array = @[@1, @"string"];
659+
[object mts_setValue:array forKey:@"mutable_set"];
660+
661+
XCTAssert([object.mutableSet isKindOfClass:NSMutableSet.class], @"Failed to create mutable set");
662+
XCTAssertEqualObjects([NSSet setWithArray:array], object.mutableSet, @"Failed to map mutable set %@", array.description);
663+
}
664+
665+
- (void)testOrderedSet
666+
{
667+
MJTestMotisMappingObject *object = [MJTestMotisMappingObject new];
668+
669+
NSArray *array = @[@1, @"string"];
670+
[object mts_setValue:array forKey:@"ordered_set"];
671+
672+
XCTAssert([object.orderedSet isKindOfClass:NSOrderedSet.class], @"Failed to create ordered set");
673+
XCTAssertEqualObjects([NSOrderedSet orderedSetWithArray:array], object.orderedSet, @"Failed to map ordered set %@", array.description);
674+
}
675+
676+
- (void)testMutableOrderedSet
677+
{
678+
MJTestMotisMappingObject *object = [MJTestMotisMappingObject new];
679+
680+
NSArray *array = @[@1, @"string"];
681+
[object mts_setValue:array forKey:@"mutable_ordered_set"];
682+
683+
XCTAssert([object.mutableOrderedSet isKindOfClass:NSMutableOrderedSet.class], @"Failed to create mutable ordered set");
684+
XCTAssertEqualObjects([NSMutableOrderedSet orderedSetWithArray:array], object.mutableOrderedSet, @"Failed to map mutable ordered set %@", array.description);
685+
}
686+
632687
#pragma mark - UNDEFINED MAPPINGS
633688

634689
// ------------------------------------------------------------------------------------------------------------------------ //

SampleProject/Motis Tests/Validation Test/MJTestMotisMappingObject.m

+6
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ + (NSDictionary*)mts_mapping
4343
@"url_array": mts_key(urlsArray),
4444
@"date_array": mts_key(datesArray),
4545

46+
@"mutable_array": mts_key(mutableArray),
47+
@"set": mts_key(set),
48+
@"mutable_set": mts_key(mutableSet),
49+
@"ordered_set": mts_key(orderedSet),
50+
@"mutable_ordered_set": mts_key(mutableOrderedSet),
51+
4652
@"unsigned_enum": mts_key(unsignedEnum),
4753
@"signed_enum": mts_key(signedEnum),
4854

SampleProject/Motis Tests/Validation Test/MJTestObject.h

+6
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ typedef NS_ENUM(NSInteger, MJSignedEnum)
5656
@property (nonatomic, strong) NSArray *urlsArray;
5757
@property (nonatomic, strong) NSArray *datesArray;
5858

59+
@property (nonatomic, strong) NSMutableArray *mutableArray;
60+
@property (nonatomic, strong) NSSet *set;
61+
@property (nonatomic, strong) NSMutableSet *mutableSet;
62+
@property (nonatomic, strong) NSOrderedSet *orderedSet;
63+
@property (nonatomic, strong) NSMutableOrderedSet *mutableOrderedSet;
64+
5965
@property (nonatomic, assign) MJUnsignedEnum unsignedEnum;
6066
@property (nonatomic, assign) MJSignedEnum signedEnum;
6167

0 commit comments

Comments
 (0)