YYModel icon indicating copy to clipboard operation
YYModel copied to clipboard

Fix NSValue bug; update example code

Open heistings opened this issue 8 years ago • 1 comments

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]);
}

heistings avatar Jan 25 '18 13:01 heistings

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%) :arrow_down:
YYModel/YYClassInfo.m 96.92% <0%> (-2.7%) :arrow_down:

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.

codecov-io avatar Jan 25 '18 14:01 codecov-io