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

Fix NSValue bug; update example code #268

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

heistings
Copy link

@heistings heistings commented Jan 25, 2018

If not fixed, YYModel will not pass the Test below:

@interface YYNSValueTestObject : NSObject

@property (nonatomic, strong) NSValue *point;
@property (nonatomic, strong) NSValue *vector;
@property (nonatomic, strong) NSValue *size;
@property (nonatomic, strong) NSValue *rect;
@property (nonatomic, strong) NSValue *affine_transform;
@property (nonatomic, strong) NSValue *edge_insets;
@property (nonatomic, strong) NSValue *directional_edge_insets;
@property (nonatomic, strong) NSValue *offset;
@property (nonatomic, strong) NSValue *range;

@end
- (void)testYYModelWithNSValue
{
    YYNSValueTestObject *object = [YYNSValueTestObject new];
    object.point = [NSValue valueWithCGPoint:CGPointMake(10, 10)];
    object.vector = [NSValue valueWithCGVector:CGVectorMake(5, 5)];
    object.size = [NSValue valueWithCGSize:CGSizeMake(100, 100)];
    object.rect = [NSValue valueWithCGRect:CGRectMake(100, 100, 100, 100)];
    object.affine_transform = [NSValue valueWithCGAffineTransform:CGAffineTransformMake(5, 5, 5, 5, 5, 5)];
    object.edge_insets = [NSValue valueWithUIEdgeInsets:UIEdgeInsetsMake(5, 5, 5, 5)];
    object.directional_edge_insets = [NSValue valueWithDirectionalEdgeInsets:NSDirectionalEdgeInsetsMake(5, 5, 5, 5)];
    object.offset = [NSValue valueWithUIOffset:UIOffsetMake(5, 5)];
    object.range = [NSValue valueWithRange:NSMakeRange(1, 1)];
    
    NSDictionary *dict = [object yy_modelToJSONObject];
    
    YYNSValueTestObject *targetObject = [YYNSValueTestObject yy_modelWithDictionary:dict];
    XCTAssert([object.point isEqualToValue:targetObject.point]);
    XCTAssert([object.vector isEqualToValue:targetObject.vector]);
    XCTAssert([object.size isEqualToValue:targetObject.size]);
    XCTAssert([object.rect isEqualToValue:targetObject.rect]);
    XCTAssert([object.affine_transform isEqualToValue:targetObject.affine_transform]);
    XCTAssert([object.edge_insets isEqualToValue:targetObject.edge_insets]);
    XCTAssert([object.directional_edge_insets isEqualToValue:targetObject.directional_edge_insets]);
    XCTAssert([object.offset isEqualToValue:targetObject.offset]);
    XCTAssert([object.range isEqualToValue:targetObject.range]);
}

@codecov-io
Copy link

codecov-io commented Jan 25, 2018

Codecov Report

Merging #268 into master will decrease coverage by 5.45%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #268      +/-   ##
==========================================
- Coverage   99.28%   93.83%   -5.46%     
==========================================
  Files           2        2              
  Lines        1540     1541       +1     
  Branches        0      423     +423     
==========================================
- Hits         1529     1446      -83     
+ Misses         11        7       -4     
- Partials        0       88      +88
Impacted Files Coverage Δ
YYModel/NSObject+YYModel.m 93.2% <0%> (-6.02%) ⬇️
YYModel/YYClassInfo.m 96.92% <0%> (-2.7%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1230e60...e91ac6c. Read the comment docs.

@heistings heistings changed the title update example code Fix NSValue bug; update example code Jan 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants