|
29 | 29 | // 3. This notice may not be removed or altered from any source distribution. |
30 | 30 | // |
31 | 31 |
|
32 | | -import XCTest |
| 32 | +import Testing |
33 | 33 | @testable import SwiftDrawDOM |
34 | 34 |
|
35 | | -final class DOMElementTests: XCTestCase { |
36 | | - |
37 | | - func testLine() { |
38 | | - let element = DOM.createLine() |
39 | | - var another = DOM.createLine() |
40 | | - |
41 | | - XCTAssertEqual(element, another) |
42 | | - |
43 | | - another.x1 = 1 |
44 | | - XCTAssertNotEqual(element, another) |
45 | | - |
46 | | - another = DOM.createLine() |
47 | | - another.attributes.fill = .color(.keyword(.black)) |
48 | | - XCTAssertNotEqual(element, another) |
49 | | - |
50 | | - another.attributes.fill = nil |
51 | | - XCTAssertEqual(element, another) |
52 | | - } |
53 | | - |
54 | | - func testCircle() { |
55 | | - let element = DOM.createCircle() |
56 | | - var another = DOM.createCircle() |
57 | | - |
58 | | - XCTAssertEqual(element, another) |
59 | | - |
60 | | - another.cx = 1 |
61 | | - XCTAssertNotEqual(element, another) |
62 | | - |
63 | | - another = DOM.createCircle() |
64 | | - another.attributes.fill = .color(.keyword(.black)) |
65 | | - XCTAssertNotEqual(element, another) |
66 | | - |
67 | | - another.attributes.fill = nil |
68 | | - XCTAssertEqual(element, another) |
69 | | - } |
70 | | - |
71 | | - func testEllipse() { |
72 | | - let element = DOM.createEllipse() |
73 | | - var another = DOM.createEllipse() |
74 | | - |
75 | | - XCTAssertEqual(element, another) |
76 | | - |
77 | | - another.cx = 1 |
78 | | - XCTAssertNotEqual(element, another) |
79 | | - |
80 | | - another = DOM.createEllipse() |
81 | | - another.attributes.fill = .color(.keyword(.black)) |
82 | | - XCTAssertNotEqual(element, another) |
83 | | - |
84 | | - another.attributes.fill = nil |
85 | | - XCTAssertEqual(element, another) |
86 | | - } |
87 | | - |
88 | | - func testRect() { |
89 | | - let element = DOM.createRect() |
90 | | - var another = DOM.createRect() |
91 | | - |
92 | | - XCTAssertEqual(element, another) |
93 | | - |
94 | | - another.x = 1 |
95 | | - XCTAssertNotEqual(element, another) |
96 | | - |
97 | | - another = DOM.createRect() |
98 | | - another.attributes.fill = .color(.keyword(.black)) |
99 | | - XCTAssertNotEqual(element, another) |
100 | | - |
101 | | - another.attributes.fill = nil |
102 | | - XCTAssertEqual(element, another) |
103 | | - } |
104 | | - |
105 | | - func testPolygon() { |
106 | | - let element = DOM.createPolygon() |
107 | | - var another = DOM.createPolygon() |
108 | | - |
109 | | - XCTAssertEqual(element, another) |
110 | | - |
111 | | - another.points.append(DOM.Point(6, 7)) |
112 | | - XCTAssertNotEqual(element, another) |
113 | | - |
114 | | - another = DOM.createPolygon() |
115 | | - another.attributes.fill = .color(.keyword(.black)) |
116 | | - XCTAssertNotEqual(element, another) |
117 | | - |
118 | | - another.attributes.fill = nil |
119 | | - XCTAssertEqual(element, another) |
120 | | - } |
121 | | - |
122 | | - func testPolyline() { |
123 | | - let element = DOM.createPolyline() |
124 | | - var another = DOM.createPolyline() |
125 | | - |
126 | | - XCTAssertEqual(element, another) |
127 | | - |
128 | | - another.points.append(DOM.Point(6, 7)) |
129 | | - XCTAssertNotEqual(element, another) |
130 | | - |
131 | | - another = DOM.createPolyline() |
132 | | - another.attributes.fill = .color(.keyword(.black)) |
133 | | - XCTAssertNotEqual(element, another) |
134 | | - |
135 | | - another.attributes.fill = nil |
136 | | - XCTAssertEqual(element, another) |
137 | | - } |
138 | | - |
139 | | - func testText() { |
140 | | - let element = DOM.createText() |
141 | | - var another = DOM.createText() |
142 | | - |
143 | | - XCTAssertEqual(element, another) |
144 | | - |
145 | | - another.value = "Simon" |
146 | | - XCTAssertNotEqual(element, another) |
147 | | - |
148 | | - another = DOM.createText() |
149 | | - another.attributes.fill = .color(.keyword(.black)) |
150 | | - XCTAssertNotEqual(element, another) |
151 | | - |
152 | | - another.attributes.fill = nil |
153 | | - XCTAssertEqual(element, another) |
154 | | - } |
155 | | - |
156 | | - func testGroup() { |
157 | | - let group = DOM.createGroup() |
158 | | - var another = DOM.createGroup() |
159 | | - |
160 | | - XCTAssertEqual(group, another) |
161 | | - |
162 | | - another.childElements.append(DOM.createCircle()) |
163 | | - XCTAssertNotEqual(group, another) |
164 | | - |
165 | | - another = DOM.createGroup() |
166 | | - another.attributes.fill = .color(.keyword(.black)) |
167 | | - XCTAssertNotEqual(group, another) |
168 | | - |
169 | | - another.attributes.fill = nil |
170 | | - XCTAssertEqual(group, another) |
171 | | - } |
| 35 | +struct DOMElementTests { |
| 36 | + |
| 37 | + @Test |
| 38 | + func line() { |
| 39 | + let element = DOM.createLine() |
| 40 | + var another = DOM.createLine() |
| 41 | + |
| 42 | + #expect(element == another) |
| 43 | + |
| 44 | + another.x1 = 1 |
| 45 | + #expect(element != another) |
| 46 | + |
| 47 | + another = DOM.createLine() |
| 48 | + another.attributes.fill = .color(.keyword(.black)) |
| 49 | + #expect(element != another) |
| 50 | + |
| 51 | + another.attributes.fill = nil |
| 52 | + #expect(element == another) |
| 53 | + } |
| 54 | + |
| 55 | + @Test |
| 56 | + func circle() { |
| 57 | + let element = DOM.createCircle() |
| 58 | + var another = DOM.createCircle() |
| 59 | + |
| 60 | + #expect(element == another) |
| 61 | + |
| 62 | + another.cx = 1 |
| 63 | + #expect(element != another) |
| 64 | + |
| 65 | + another = DOM.createCircle() |
| 66 | + another.attributes.fill = .color(.keyword(.black)) |
| 67 | + #expect(element != another) |
| 68 | + |
| 69 | + another.attributes.fill = nil |
| 70 | + #expect(element == another) |
| 71 | + } |
| 72 | + |
| 73 | + @Test |
| 74 | + func ellipse() { |
| 75 | + let element = DOM.createEllipse() |
| 76 | + var another = DOM.createEllipse() |
| 77 | + |
| 78 | + #expect(element == another) |
| 79 | + |
| 80 | + another.cx = 1 |
| 81 | + #expect(element != another) |
| 82 | + |
| 83 | + another = DOM.createEllipse() |
| 84 | + another.attributes.fill = .color(.keyword(.black)) |
| 85 | + #expect(element != another) |
| 86 | + |
| 87 | + another.attributes.fill = nil |
| 88 | + #expect(element == another) |
| 89 | + } |
| 90 | + |
| 91 | + @Test |
| 92 | + func rect() { |
| 93 | + let element = DOM.createRect() |
| 94 | + var another = DOM.createRect() |
| 95 | + |
| 96 | + #expect(element == another) |
| 97 | + |
| 98 | + another.x = 1 |
| 99 | + #expect(element != another) |
| 100 | + |
| 101 | + another = DOM.createRect() |
| 102 | + another.attributes.fill = .color(.keyword(.black)) |
| 103 | + #expect(element != another) |
| 104 | + |
| 105 | + another.attributes.fill = nil |
| 106 | + #expect(element == another) |
| 107 | + } |
| 108 | + |
| 109 | + @Test |
| 110 | + func polygon() { |
| 111 | + let element = DOM.createPolygon() |
| 112 | + var another = DOM.createPolygon() |
| 113 | + |
| 114 | + #expect(element == another) |
| 115 | + |
| 116 | + another.points.append(DOM.Point(6, 7)) |
| 117 | + #expect(element != another) |
| 118 | + |
| 119 | + another = DOM.createPolygon() |
| 120 | + another.attributes.fill = .color(.keyword(.black)) |
| 121 | + #expect(element != another) |
| 122 | + |
| 123 | + another.attributes.fill = nil |
| 124 | + #expect(element == another) |
| 125 | + } |
| 126 | + |
| 127 | + @Test |
| 128 | + func polyline() { |
| 129 | + let element = DOM.createPolyline() |
| 130 | + var another = DOM.createPolyline() |
| 131 | + |
| 132 | + #expect(element == another) |
| 133 | + |
| 134 | + another.points.append(DOM.Point(6, 7)) |
| 135 | + #expect(element != another) |
| 136 | + |
| 137 | + another = DOM.createPolyline() |
| 138 | + another.attributes.fill = .color(.keyword(.black)) |
| 139 | + #expect(element != another) |
| 140 | + |
| 141 | + another.attributes.fill = nil |
| 142 | + #expect(element == another) |
| 143 | + } |
| 144 | + |
| 145 | + @Test |
| 146 | + func text() { |
| 147 | + let element = DOM.createText() |
| 148 | + var another = DOM.createText() |
| 149 | + |
| 150 | + #expect(element == another) |
| 151 | + |
| 152 | + another.value = "Simon" |
| 153 | + #expect(element != another) |
| 154 | + |
| 155 | + another = DOM.createText() |
| 156 | + another.attributes.fill = .color(.keyword(.black)) |
| 157 | + #expect(element != another) |
| 158 | + |
| 159 | + another.attributes.fill = nil |
| 160 | + #expect(element == another) |
| 161 | + } |
| 162 | + |
| 163 | + @Test |
| 164 | + func group() { |
| 165 | + let group = DOM.createGroup() |
| 166 | + var another = DOM.createGroup() |
| 167 | + |
| 168 | + #expect(group == another) |
| 169 | + |
| 170 | + another.childElements.append(DOM.createCircle()) |
| 171 | + #expect(group != another) |
| 172 | + |
| 173 | + another = DOM.createGroup() |
| 174 | + another.attributes.fill = .color(.keyword(.black)) |
| 175 | + #expect(group != another) |
| 176 | + |
| 177 | + another.attributes.fill = nil |
| 178 | + #expect(group == another) |
| 179 | + } |
172 | 180 | } |
0 commit comments