Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue w/ NSCopying being used before SEGSerialization #962

Merged
merged 1 commit into from
Nov 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Segment/Internal/SEGUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -543,10 +543,10 @@ - (id)serializableDeepCopy:(BOOL)mutable

if ([aValue conformsToProtocol:@protocol(SEGSerializableDeepCopy)]) {
theCopy = [aValue serializableDeepCopy:mutable];
} else if ([aValue conformsToProtocol:@protocol(NSCopying)]) {
theCopy = [aValue copy];
} else if ([aValue conformsToProtocol:@protocol(SEGSerializable)]) {
theCopy = [aValue serializeToAppropriateType];
} else if ([aValue conformsToProtocol:@protocol(NSCopying)]) {
theCopy = [aValue copy];
} else {
theCopy = aValue;
}
Expand Down Expand Up @@ -594,10 +594,10 @@ -(id)serializableDeepCopy:(BOOL)mutable

if ([aValue conformsToProtocol:@protocol(SEGSerializableDeepCopy)]) {
theCopy = [aValue serializableDeepCopy:mutable];
} else if ([aValue conformsToProtocol:@protocol(NSCopying)]) {
theCopy = [aValue copy];
} else if ([aValue conformsToProtocol:@protocol(SEGSerializable)]) {
theCopy = [aValue serializeToAppropriateType];
} else if ([aValue conformsToProtocol:@protocol(NSCopying)]) {
theCopy = [aValue copy];
} else {
theCopy = aValue;
}
Expand Down
10 changes: 8 additions & 2 deletions SegmentTests/SerializationTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,17 @@ - (void)testSEGSerialization {
XCTAssertThrows([nonserializable serializableDeepCopy]);

NSDictionary *testCoersion1 = @{@"test1": @[date], @"test2": url, @"test3": @1};
NSDictionary *coersionResult1 = SEGCoerceDictionary(testCoersion1);
XCTAssertNotNil(coersionResult1);
NSDictionary *coersionResult = SEGCoerceDictionary(testCoersion1);
XCTAssertNotNil(coersionResult);

NSDictionary *testCoersion2 = @{@"test1": @[date], @"test2": url, @"test3": @1, @"test4": data};
XCTAssertThrows(SEGCoerceDictionary(testCoersion2));

NSError *error = nil;
NSData *json = [NSJSONSerialization dataWithJSONObject:coersionResult options:NSJSONWritingPrettyPrinted error:&error];

XCTAssertNil(error);
XCTAssertNotNil(json);
}

@end