@@ -4,198 +4,6 @@ import XCTest
44
55final class LaTeXSwiftUITests : XCTestCase {
66
7- func assertComponent( _ components: [ Component ] , _ index: Int , _ text: String , _ type: Component . ComponentType , file: StaticString = #file, line: UInt = #line) {
8- guard index < components. count else {
9- XCTFail ( )
10- return
11- }
12- XCTAssertEqual ( components [ index] , Component ( text: text, type: type) )
13- }
14-
15- func testParseEmpty( ) {
16- let input = " "
17- let components = Parser . parse ( input)
18- XCTAssertEqual ( components. count, 0 )
19- }
20-
21- func testParseTextOnly( ) {
22- let input = " Hello, World! "
23- let components = Parser . parse ( input)
24- XCTAssertEqual ( components. count, 1 )
25- XCTAssertEqual ( components [ 0 ] . text, input)
26- }
27-
28- func testParseDollarOnly( ) {
29- let input = " $ \\ TeX$ "
30- let components = Parser . parse ( input)
31- XCTAssertEqual ( components. count, 1 )
32- assertComponent ( components, 0 , " \\ TeX " , . inlineEquation)
33- }
34-
35- func testParseDollarOnly_Normal( ) {
36- let input = " Hello, $ \\ TeX$! "
37- let components = Parser . parse ( input)
38- XCTAssertEqual ( components. count, 3 )
39- assertComponent ( components, 0 , " Hello, " , . text)
40- assertComponent ( components, 1 , " \\ TeX " , . inlineEquation)
41- assertComponent ( components, 2 , " ! " , . text)
42- }
43-
44- func testParseDollarOnly_LeftEscaped( ) {
45- let input = " Hello, \\ $ \\ TeX$! "
46- let components = Parser . parse ( input)
47- XCTAssertEqual ( components. count, 1 )
48- assertComponent ( components, 0 , input, . text)
49- }
50-
51- func testParseDollarOnly_RightEscaped( ) {
52- let input = " Hello, $ \\ TeX \\ $! "
53- let components = Parser . parse ( input)
54- XCTAssertEqual ( components. count, 1 )
55- assertComponent ( components, 0 , input, . text)
56- }
57-
58- func testParseDoubleDollarOnly( ) {
59- let input = " $$ \\ TeX$$ "
60- let components = Parser . parse ( input)
61- XCTAssertEqual ( components. count, 1 )
62- assertComponent ( components, 0 , " \\ TeX " , . texEquation)
63- }
64-
65- func testParseDoubleDollarOnly_Normal( ) {
66- let input = " Hello, $$ \\ TeX$$! "
67- let components = Parser . parse ( input)
68- XCTAssertEqual ( components. count, 3 )
69- assertComponent ( components, 0 , " Hello, " , . text)
70- assertComponent ( components, 1 , " \\ TeX " , . texEquation)
71- assertComponent ( components, 2 , " ! " , . text)
72- }
73-
74- func testParseDoubleDollarOnly_LeftEscaped( ) {
75- let input = " Hello, \\ $$ \\ TeX$$! "
76- let components = Parser . parse ( input)
77- XCTAssertEqual ( components. count, 1 )
78- assertComponent ( components, 0 , input, . text)
79- }
80-
81- func testParseDoubleDollarOnly_RightEscaped( ) {
82- let input = " Hello, $$ \\ TeX \\ $$! "
83- let components = Parser . parse ( input)
84- XCTAssertEqual ( components. count, 1 )
85- assertComponent ( components, 0 , input, . text)
86- }
87-
88- func testParseBracketsOnly( ) {
89- let input = " \\ [ \\ TeX \\ ] "
90- let components = Parser . parse ( input)
91- XCTAssertEqual ( components. count, 1 )
92- assertComponent ( components, 0 , " \\ TeX " , . blockEquation)
93- }
94-
95- func testParseBracketsOnly_Normal( ) {
96- let input = " Hello, \\ [ \\ TeX \\ ]! "
97- let components = Parser . parse ( input)
98- XCTAssertEqual ( components. count, 3 )
99- assertComponent ( components, 0 , " Hello, " , . text)
100- assertComponent ( components, 1 , " \\ TeX " , . blockEquation)
101- assertComponent ( components, 2 , " ! " , . text)
102- }
103-
104- func testParseBracketsOnly_LeftEscaped( ) {
105- let input = " Hello, \\ \\ [ \\ TeX \\ ]! "
106- let components = Parser . parse ( input)
107- XCTAssertEqual ( components. count, 1 )
108- assertComponent ( components, 0 , input, . text)
109- }
110-
111- func testParseBracketsOnly_RightEscaped( ) {
112- let input = " Hello, \\ [ \\ TeX \\ \\ ]! "
113- let components = Parser . parse ( input)
114- XCTAssertEqual ( components. count, 1 )
115- assertComponent ( components, 0 , input, . text)
116- }
117-
118- func testParseBracketsOnly_LineBreak( ) {
119- let input = " Hello, \\ [ \\ TeX \n \\ \\ ]! "
120- let components = Parser . parse ( input)
121- XCTAssertEqual ( components. count, 1 )
122- assertComponent ( components, 0 , input, . text)
123- }
124-
125- func testParseBeginEndOnly( ) {
126- let input = " \\ begin{equation} \\ TeX \\ end{equation} "
127- let components = Parser . parse ( input)
128- XCTAssertEqual ( components. count, 1 )
129- assertComponent ( components, 0 , " \\ TeX " , . namedEquation)
130- }
131-
132- func testParseBeginEndOnly_Normal( ) {
133- let input = " Hello, \\ begin{equation} \\ TeX \\ end{equation}! "
134- let components = Parser . parse ( input)
135- XCTAssertEqual ( components. count, 3 )
136- assertComponent ( components, 0 , " Hello, " , . text)
137- assertComponent ( components, 1 , " \\ TeX " , . namedEquation)
138- assertComponent ( components, 2 , " ! " , . text)
139- }
140-
141- func testParseBeginEndOnly_LeftEscaped( ) {
142- let input = " Hello, \\ \\ begin{equation} \\ TeX \\ end{equation}! "
143- let components = Parser . parse ( input)
144- XCTAssertEqual ( components. count, 1 )
145- assertComponent ( components, 0 , input, . text)
146- }
147-
148- func testParseBeginEndOnly_RightEscaped( ) {
149- let input = " Hello, \\ begin{equation} \\ TeX \\ \\ end{equation}! "
150- let components = Parser . parse ( input)
151- XCTAssertEqual ( components. count, 1 )
152- assertComponent ( components, 0 , input, . text)
153- }
154-
155- func testParseBeginEndOnly_LineBreak( ) {
156- let input = " Hello, \\ begin{equation} \\ TeX \n \\ \\ end{equation}! "
157- let components = Parser . parse ( input)
158- XCTAssertEqual ( components. count, 1 )
159- assertComponent ( components, 0 , input, . text)
160- }
161-
162- func testParseBeginEndStarOnly( ) {
163- let input = " \\ begin{equation*} \\ TeX \\ end{equation*} "
164- let components = Parser . parse ( input)
165- XCTAssertEqual ( components. count, 1 )
166- assertComponent ( components, 0 , " \\ TeX " , . namedNoNumberEquation)
167- }
168-
169- func testParseBeginEndStarOnly_Normal( ) {
170- let input = " Hello, \\ begin{equation*} \\ TeX \\ end{equation*}! "
171- let components = Parser . parse ( input)
172- XCTAssertEqual ( components. count, 3 )
173- assertComponent ( components, 0 , " Hello, " , . text)
174- assertComponent ( components, 1 , " \\ TeX " , . namedNoNumberEquation)
175- assertComponent ( components, 2 , " ! " , . text)
176- }
177-
178- func testParseBeginEndStarOnly_LeftEscaped( ) {
179- let input = " Hello, \\ \\ begin{equation*} \\ TeX \\ end{equation*}! "
180- let components = Parser . parse ( input)
181- XCTAssertEqual ( components. count, 1 )
182- assertComponent ( components, 0 , input, . text)
183- }
184-
185- func testParseBeginEndStarOnly_RightEscaped( ) {
186- let input = " Hello, \\ begin{equation*} \\ TeX \\ \\ end{equation*}! "
187- let components = Parser . parse ( input)
188- XCTAssertEqual ( components. count, 1 )
189- assertComponent ( components, 0 , input, . text)
190- }
191-
192- func testParseBeginEndStarOnly_LineBreak( ) {
193- let input = " Hello, \\ begin{equation*} \\ TeX \n \\ \\ end{equation*}! "
194- let components = Parser . parse ( input)
195- XCTAssertEqual ( components. count, 1 )
196- assertComponent ( components, 0 , input, . text)
197- }
198-
1997 func testSVGGeometry_parseAlignment( ) {
2008 let input = " \" vertical-align: -1.602ex; \" "
2019 let value = SVGGeometry . parseAlignment ( from: input)
0 commit comments