@@ -19,17 +19,6 @@ final class DemoTextAttachment: TextAttachment {
1919class TypesetterTests : XCTestCase {
2020 // NOTE: makes chars that are ~6.18 pts wide
2121 let attributes : [ NSAttributedString . Key : Any ] = [ . font: NSFont . monospacedSystemFont ( ofSize: 10 , weight: . regular) ]
22- let limitedLineWidthDisplayData = TextLine . DisplayData (
23- maxWidth: 150 ,
24- lineHeightMultiplier: 1.0 ,
25- estimatedLineHeight: 20.0
26- )
27- let unlimitedLineWidthDisplayData = TextLine . DisplayData (
28- maxWidth: . infinity,
29- lineHeightMultiplier: 1.0 ,
30- estimatedLineHeight: 20.0
31- )
32-
3322 var typesetter : Typesetter !
3423
3524 override func setUp( ) {
@@ -41,8 +30,12 @@ class TypesetterTests: XCTestCase {
4130 typesetter. typeset (
4231 NSAttributedString ( string: " testline \n " ) ,
4332 documentRange: NSRange ( location: 0 , length: 9 ) ,
44- displayData: unlimitedLineWidthDisplayData,
45- breakStrategy: . word,
33+ displayData: TextLine . DisplayData (
34+ maxWidth: . infinity,
35+ lineHeightMultiplier: 1.0 ,
36+ estimatedLineHeight: 20.0 ,
37+ breakStrategy: . word
38+ ) ,
4639 markedRanges: nil
4740 )
4841
@@ -51,8 +44,12 @@ class TypesetterTests: XCTestCase {
5144 typesetter. typeset (
5245 NSAttributedString ( string: " testline \n " ) ,
5346 documentRange: NSRange ( location: 0 , length: 9 ) ,
54- displayData: unlimitedLineWidthDisplayData,
55- breakStrategy: . character,
47+ displayData: TextLine . DisplayData (
48+ maxWidth: . infinity,
49+ lineHeightMultiplier: 1.0 ,
50+ estimatedLineHeight: 20.0 ,
51+ breakStrategy: . character
52+ ) ,
5653 markedRanges: nil
5754 )
5855
@@ -63,8 +60,12 @@ class TypesetterTests: XCTestCase {
6360 typesetter. typeset (
6461 NSAttributedString ( string: " testline \r " ) ,
6562 documentRange: NSRange ( location: 0 , length: 9 ) ,
66- displayData: unlimitedLineWidthDisplayData,
67- breakStrategy: . word,
63+ displayData: TextLine . DisplayData (
64+ maxWidth: . infinity,
65+ lineHeightMultiplier: 1.0 ,
66+ estimatedLineHeight: 20.0 ,
67+ breakStrategy: . word
68+ ) ,
6869 markedRanges: nil
6970 )
7071
@@ -73,8 +74,12 @@ class TypesetterTests: XCTestCase {
7374 typesetter. typeset (
7475 NSAttributedString ( string: " testline \r " ) ,
7576 documentRange: NSRange ( location: 0 , length: 9 ) ,
76- displayData: unlimitedLineWidthDisplayData,
77- breakStrategy: . character,
77+ displayData: TextLine . DisplayData (
78+ maxWidth: . infinity,
79+ lineHeightMultiplier: 1.0 ,
80+ estimatedLineHeight: 20.0 ,
81+ breakStrategy: . character
82+ ) ,
7883 markedRanges: nil
7984 )
8085
@@ -85,8 +90,12 @@ class TypesetterTests: XCTestCase {
8590 typesetter. typeset (
8691 NSAttributedString ( string: " testline \r \n " ) ,
8792 documentRange: NSRange ( location: 0 , length: 10 ) ,
88- displayData: unlimitedLineWidthDisplayData,
89- breakStrategy: . word,
93+ displayData: TextLine . DisplayData (
94+ maxWidth: . infinity,
95+ lineHeightMultiplier: 1.0 ,
96+ estimatedLineHeight: 20.0 ,
97+ breakStrategy: . word
98+ ) ,
9099 markedRanges: nil
91100 )
92101
@@ -95,8 +104,12 @@ class TypesetterTests: XCTestCase {
95104 typesetter. typeset (
96105 NSAttributedString ( string: " testline \r \n " ) ,
97106 documentRange: NSRange ( location: 0 , length: 10 ) ,
98- displayData: unlimitedLineWidthDisplayData,
99- breakStrategy: . character,
107+ displayData: TextLine . DisplayData (
108+ maxWidth: . infinity,
109+ lineHeightMultiplier: 1.0 ,
110+ estimatedLineHeight: 20.0 ,
111+ breakStrategy: . character
112+ ) ,
100113 markedRanges: nil
101114 )
102115
@@ -108,8 +121,12 @@ class TypesetterTests: XCTestCase {
108121 typesetter. typeset (
109122 NSAttributedString ( string: String ( repeating: " A " , count: 1000 ) , attributes: attributes) ,
110123 documentRange: NSRange ( location: 0 , length: 1000 ) ,
111- displayData: limitedLineWidthDisplayData, // 150 px
112- breakStrategy: . character,
124+ displayData: TextLine . DisplayData (
125+ maxWidth: 150 ,
126+ lineHeightMultiplier: 1.0 ,
127+ estimatedLineHeight: 20.0 ,
128+ breakStrategy: . character
129+ ) ,
113130 markedRanges: nil ,
114131 attachments: [ ]
115132 )
@@ -132,8 +149,12 @@ class TypesetterTests: XCTestCase {
132149 typesetter. typeset (
133150 NSAttributedString ( string: " ABC " ) ,
134151 documentRange: NSRange ( location: 0 , length: 3 ) ,
135- displayData: unlimitedLineWidthDisplayData,
136- breakStrategy: . character,
152+ displayData: TextLine . DisplayData (
153+ maxWidth: . infinity,
154+ lineHeightMultiplier: 1.0 ,
155+ estimatedLineHeight: 20.0 ,
156+ breakStrategy: . character
157+ ) ,
137158 markedRanges: nil ,
138159 attachments: [ TextAttachmentBox ( range: NSRange ( location: 1 , length: 1 ) , attachment: attachment) ]
139160 )
@@ -158,8 +179,12 @@ class TypesetterTests: XCTestCase {
158179 typesetter. typeset (
159180 NSAttributedString ( string: " ABC " ) ,
160181 documentRange: NSRange ( location: 0 , length: 3 ) ,
161- displayData: unlimitedLineWidthDisplayData,
162- breakStrategy: . character,
182+ displayData: TextLine . DisplayData (
183+ maxWidth: . infinity,
184+ lineHeightMultiplier: 1.0 ,
185+ estimatedLineHeight: 20.0 ,
186+ breakStrategy: . character
187+ ) ,
163188 markedRanges: nil ,
164189 attachments: [ TextAttachmentBox ( range: NSRange ( location: 0 , length: 3 ) , attachment: attachment) ]
165190 )
@@ -184,8 +209,12 @@ class TypesetterTests: XCTestCase {
184209 typesetter. typeset (
185210 NSAttributedString ( string: " ABC123 " , attributes: attributes) ,
186211 documentRange: NSRange ( location: 0 , length: 6 ) ,
187- displayData: limitedLineWidthDisplayData, // 150 px
188- breakStrategy: . character,
212+ displayData: TextLine . DisplayData (
213+ maxWidth: 150 ,
214+ lineHeightMultiplier: 1.0 ,
215+ estimatedLineHeight: 20.0 ,
216+ breakStrategy: . character
217+ ) ,
189218 markedRanges: nil ,
190219 attachments: [ . init( range: NSRange ( location: 1 , length: 1 ) , attachment: attachment) ]
191220 )
@@ -211,8 +240,12 @@ class TypesetterTests: XCTestCase {
211240 typesetter. typeset (
212241 NSAttributedString ( string: " ABC123 " , attributes: attributes) ,
213242 documentRange: NSRange ( location: 0 , length: 6 ) ,
214- displayData: limitedLineWidthDisplayData, // 150 px
215- breakStrategy: . character,
243+ displayData: TextLine . DisplayData (
244+ maxWidth: 150 ,
245+ lineHeightMultiplier: 1.0 ,
246+ estimatedLineHeight: 20.0 ,
247+ breakStrategy: . character
248+ ) ,
216249 markedRanges: nil ,
217250 attachments: [ . init( range: NSRange ( location: 1 , length: 1 ) , attachment: attachment) ]
218251 )
0 commit comments