Skip to content

Commit

Permalink
Update unit test to exercise the code paths in CTFramesetterSuggestFr…
Browse files Browse the repository at this point in the history
…ameSizeForAttributedStringWithConstraints() with the numberOfLines values of 0, 1, and 2.
  • Loading branch information
dillan committed Nov 18, 2016
1 parent 4279e3d commit 3871c95
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Example/TTTAttributedLabelTests/TTTAttributedLabelTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -298,17 +298,21 @@ - (void)testTextRectWithoutAttributedText {
XCTAssertTrue(CGRectEqualToRect(rect, CGRectMake(0, 0, 0, 0)));
}

- (void)testSizeToFitRequiresNumberOfLines {
label.numberOfLines = 0;
- (void)testSizeToFitNumberOfLines {
label.attributedTruncationToken = [[NSAttributedString alloc] initWithString:@"[more]"
attributes:@{ NSFontAttributeName : [UIFont boldSystemFontOfSize:14],
NSForegroundColorAttributeName : [UIColor greenColor] }];
label.text = [[NSAttributedString alloc] initWithString:@"Test\nString\nWith\nLines"
attributes:@{ NSFontAttributeName : [UIFont boldSystemFontOfSize:15],
NSForegroundColorAttributeName : [UIColor redColor] }];

label.numberOfLines = 0;
[label sizeToFit];
expect(label.frame.size).to.equal(CGSizeZero);
expect(label.frame.size).notTo.equal(CGSizeZero);

label.numberOfLines = 1;
[label sizeToFit];
expect(label.frame.size).notTo.equal(CGSizeZero);

label.numberOfLines = 2;
[label sizeToFit];
Expand Down

0 comments on commit 3871c95

Please sign in to comment.