@@ -26,24 +26,45 @@ import XCTest
2626
2727class HyperLabelTests : XCTestCase {
2828
29- override func setUp( ) {
30- // Put setup code here. This method is called before the invocation of each test method in the class.
31- }
29+ override func setUp( ) { }
3230
33- override func tearDown( ) {
34- // Put teardown code here. This method is called after the invocation of each test method in the class.
35- }
31+ override func tearDown( ) { }
32+
33+ func test_GivenTextWithSpecialCharacter_WhenAddLink_ThenRangesAreCorrect( ) {
34+ // Given
35+ // '’' is UTF16?
36+ let exampleText = " You’ll be happy one day. "
37+ let sut : HyperLabel = {
38+ let hyperLabel = HyperLabel ( )
39+ hyperLabel. numberOfLines = 0
40+ hyperLabel. text = exampleText
41+ hyperLabel. additionalLinkAttributes = [ . underlineStyle: NSUnderlineStyle . single. rawValue]
42+ return hyperLabel
43+ } ( )
3644
37- func testExample( ) {
38- // This is an example of a functional test case.
39- // Use XCTAssert and related functions to verify your tests produce the correct results.
45+ // When
46+ let range = exampleText. range ( of: " day " ) !
47+
48+ // Then
49+ sut. addLink ( withRange: range) { }
4050 }
4151
42- func testPerformanceExample( ) {
43- // This is an example of a performance test case.
44- self . measure {
45- // Put the code you want to measure the time of here.
46- }
52+ func test_GivenSimpleText_WhenAddLink_ThenRangesAreCorrect( ) {
53+ // Given
54+ let exampleText = " Look's good with no special characters. "
55+ let sut : HyperLabel = {
56+ let hyperLabel = HyperLabel ( )
57+ hyperLabel. numberOfLines = 0
58+ hyperLabel. text = exampleText
59+ hyperLabel. additionalLinkAttributes = [ . underlineStyle: NSUnderlineStyle . single. rawValue]
60+ return hyperLabel
61+ } ( )
62+
63+ // When
64+ let range = exampleText. range ( of: " characters " ) !
65+
66+ // Then
67+ sut. addLink ( withRange: range) { }
4768 }
4869
4970}
0 commit comments