From bde7923d76e6a6a625a975b372fa60ceb1e27d2f Mon Sep 17 00:00:00 2001 From: choefele Date: Fri, 10 Apr 2015 16:46:25 +0200 Subject: [PATCH] Add unit test for two links at the same location --- .../CCHLinkTextViewTests.m | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CCHLinkTextView Example/CCHLinkTextView ExampleTests/CCHLinkTextViewTests.m b/CCHLinkTextView Example/CCHLinkTextView ExampleTests/CCHLinkTextViewTests.m index a6c62f9..c610772 100644 --- a/CCHLinkTextView Example/CCHLinkTextView ExampleTests/CCHLinkTextViewTests.m +++ b/CCHLinkTextView Example/CCHLinkTextView ExampleTests/CCHLinkTextViewTests.m @@ -166,4 +166,18 @@ XCTAssertEqual(blockCalled, 1u); } +- (void)testEnumerateLinkRangesContainingPointOverlappingTwoLinks +{ + NSMutableAttributedString *attributedText = [self.linkTextView.attributedText mutableCopy]; + [attributedText addAttribute:CCHLinkAttributeName value:@"0" range:NSMakeRange(0, 20)]; + [attributedText addAttribute:CCHLinkAttributeName value:@"1" range:NSMakeRange(5, 20)]; + self.linkTextView.attributedText = attributedText; + + __block NSUInteger blockCalled = 0; + [self.linkTextView enumerateLinkRangesContainingLocation:CGPointMake(37, 12) usingBlock:^(NSRange range) { + blockCalled++; + }]; + XCTAssertEqual(blockCalled, 1u); +} + @end