@@ -55,6 +55,7 @@ - (void)testEmptyTruncationStringSameAsStraightTextKitTailTruncation
5555 avoidTailTruncationSet: nil ];
5656 [tailTruncater truncate ];
5757 XCTAssert (NSEqualRanges (textKitVisibleRange, tailTruncater.visibleRanges [0 ]));
58+ XCTAssert (NSEqualRanges (textKitVisibleRange, tailTruncater.firstVisibleRange ));
5859}
5960
6061- (void )testSimpleTailTruncation
@@ -80,6 +81,7 @@ - (void)testSimpleTailTruncation
8081 NSString *expectedString = @" 90's cray photo booth tote bag bespoke Carles. Plaid wayfarers..." ;
8182 XCTAssertEqualObjects (expectedString, drawnString);
8283 XCTAssert (NSEqualRanges (NSMakeRange (0 , 62 ), tailTruncater.visibleRanges [0 ]));
84+ XCTAssert (NSEqualRanges (NSMakeRange (0 , 62 ), tailTruncater.firstVisibleRange ));
8385}
8486
8587- (void )testAvoidedCharTailWordBoundaryTruncation
@@ -132,6 +134,27 @@ - (void)testAvoidedCharTailCharBoundaryTruncation
132134 XCTAssertEqualObjects (expectedString, drawnString);
133135}
134136
137+ - (void )testHandleZeroSizeConstrainedSize
138+ {
139+ CGSize constrainedSize = CGSizeZero;
140+ NSAttributedString *attributedString = [self _sentenceAttributedString ];
141+
142+ ASTextKitContext *context = [[ASTextKitContext alloc ] initWithAttributedString: attributedString
143+ lineBreakMode: NSLineBreakByWordWrapping
144+ maximumNumberOfLines: 0
145+ exclusionPaths: nil
146+ constrainedSize: constrainedSize
147+ layoutManagerCreationBlock: nil
148+ layoutManagerDelegate: nil
149+ textStorageCreationBlock: nil ];
150+ ASTextKitTailTruncater *tailTruncater = [[ASTextKitTailTruncater alloc ] initWithContext: context
151+ truncationAttributedString: [self _simpleTruncationAttributedString ]
152+ avoidTailTruncationSet: nil ];
153+ XCTAssertNoThrow ([tailTruncater truncate ]);
154+ XCTAssert (tailTruncater.visibleRanges .size () == 0 );
155+ NSEqualRanges (NSMakeRange (NSNotFound , 0 ), tailTruncater.firstVisibleRange);
156+ }
157+
135158- (void )testHandleZeroHeightConstrainedSize
136159{
137160 CGSize constrainedSize = CGSizeMake (50 , 0 );
@@ -145,9 +168,10 @@ - (void)testHandleZeroHeightConstrainedSize
145168 layoutManagerDelegate: nil
146169 textStorageCreationBlock: nil ];
147170
148- XCTAssertNoThrow ([[[ASTextKitTailTruncater alloc ] initWithContext: context
149- truncationAttributedString: [self _simpleTruncationAttributedString ]
150- avoidTailTruncationSet: [NSCharacterSet characterSetWithCharactersInString: @" ." ]] truncate ]);
171+ ASTextKitTailTruncater *tailTruncater = [[ASTextKitTailTruncater alloc ] initWithContext: context
172+ truncationAttributedString: [self _simpleTruncationAttributedString ]
173+ avoidTailTruncationSet: [NSCharacterSet characterSetWithCharactersInString: @" ." ]];
174+ XCTAssertNoThrow ([tailTruncater truncate ]);
151175}
152176
153177@end
0 commit comments