-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathCubeCurveToTests.swift
166 lines (137 loc) · 5.46 KB
/
CubeCurveToTests.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
//
// CubeCurveToTests.swift
// SVGPath
//
// Created by Tim Wood on 1/25/15.
// Copyright (c) 2015 Tim Wood. All rights reserved.
//
import XCTest
import SVGPath
class CubeCurveToTests: XCTestCase {
func testSingleAbsoluteCurveTo() {
let actual:[SVGCommand] = SVGPath("C1 2 3 4 5 6").commands
let expect:[SVGCommand] = [
SVGCommand(1.0, 2.0, 3.0, 4.0, 5.0, 6.0)
]
assertCommandsEqual(actual, expect)
}
func testMultipleAbsoluteCurveTo() {
let actual:[SVGCommand] = SVGPath("C1 2 3 4 5 6 7 8 9 10 11 12C13 14 15 16 17 18").commands
let expect:[SVGCommand] = [
SVGCommand( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0),
SVGCommand( 7.0, 8.0, 9.0, 10.0, 11.0, 12.0),
SVGCommand(13.0, 14.0, 15.0, 16.0, 17.0, 18.0)
]
assertCommandsEqual(actual, expect)
}
func testSingleRelativeCurveTo() {
let actual:[SVGCommand] = SVGPath("M8 6c1 2 3 4 5 6").commands
let expect:[SVGCommand] = [
SVGCommand(8.0, 6.0, type: .move),
SVGCommand(9.0, 8.0, 11.0, 10.0, 13.0, 12.0)
]
assertCommandsEqual(actual, expect)
}
func testMultipleRelativeCurveTo() {
let actual:[SVGCommand] = SVGPath("M1 2c3 4 5 6 7 8 9 10 11 12 13 14c1 2 3 4 5 6").commands
let expect:[SVGCommand] = [
SVGCommand(
1.0, 2.0, type: .move),
SVGCommand(
1.0 + 3.0, 2.0 + 4.0,
1.0 + 5.0, 2.0 + 6.0,
1.0 + 7.0, 2.0 + 8.0),
SVGCommand(
1.0 + 7.0 + 9.0, 2.0 + 8.0 + 10.0,
1.0 + 7.0 + 11.0, 2.0 + 8.0 + 12.0,
1.0 + 7.0 + 13.0, 2.0 + 8.0 + 14.0),
SVGCommand(
1.0 + 7.0 + 13.0 + 1.0, 2.0 + 8.0 + 14.0 + 2.0,
1.0 + 7.0 + 13.0 + 3.0, 2.0 + 8.0 + 14.0 + 4.0,
1.0 + 7.0 + 13.0 + 5.0, 2.0 + 8.0 + 14.0 + 6.0)
]
assertCommandsEqual(actual, expect)
}
func testSingleAbsoluteSmoothCurveTo() {
let actual:[SVGCommand] = SVGPath("C1 2 3 4 5 6S7 8 9 10").commands
let expect:[SVGCommand] = [
SVGCommand(1.0, 2.0, 3.0, 4.0, 5.0, 6.0),
SVGCommand(7.0, 8.0, 7.0, 8.0, 9.0, 10.0)
]
assertCommandsEqual(actual, expect)
}
func testMultipleAbsoluteSmoothCurveTo() {
let actual:[SVGCommand] = SVGPath("C1 2 3 4 5 6S1 2 3 4 5 6 7 8").commands
let expect:[SVGCommand] = [
SVGCommand(1.0, 2.0, 3.0, 4.0, 5.0, 6.0),
SVGCommand(7.0, 8.0, 1.0, 2.0, 3.0, 4.0),
SVGCommand(5.0, 6.0, 5.0, 6.0, 7.0, 8.0)
]
assertCommandsEqual(actual, expect)
}
func testSingleRelativeSmoothCurveTo() {
let actual:[SVGCommand] = SVGPath("C1 2 3 4 5 6s7 8 9 10").commands
let expect:[SVGCommand] = [
SVGCommand(1.0, 2.0, 3.0, 4.0, 5.0, 6.0),
SVGCommand(7.0, 8.0, 12.0, 14.0, 14.0, 16.0)
]
assertCommandsEqual(actual, expect)
}
func testMultipleRelativeSmoothCurveTo() {
let actual:[SVGCommand] = SVGPath("C1 2 3 4 5 6s1 2 3 4 5 6 7 8").commands
let expect:[SVGCommand] = [
SVGCommand( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0),
SVGCommand( 7.0, 8.0, 6.0, 8.0, 8.0, 10.0),
SVGCommand(10.0, 12.0, 13.0, 16.0, 15.0, 18.0)
]
assertCommandsEqual(actual, expect)
}
func testAbsoluteSmoothToAfterMoveTo() {
let actual:[SVGCommand] = SVGPath("M1 2S3 4 5 6").commands
let expect:[SVGCommand] = [
SVGCommand(1.0, 2.0, type: .move),
SVGCommand(1.0, 2.0, 3.0, 4.0, 5.0, 6.0)
]
assertCommandsEqual(actual, expect)
}
func testAbsoluteSmoothToAfterLineTo() {
let actual:[SVGCommand] = SVGPath("L1 2S3 4 5 6").commands
let expect:[SVGCommand] = [
SVGCommand(1.0, 2.0, type: .line),
SVGCommand(1.0, 2.0, 3.0, 4.0, 5.0, 6.0)
]
assertCommandsEqual(actual, expect)
}
func testAbsoluteSmoothToAfterQuadCurveTo() {
let actual:[SVGCommand] = SVGPath("Q1 2 3 4S5 6 7 8").commands
let expect:[SVGCommand] = [
SVGCommand(1.0, 2.0, 3.0, 4.0),
SVGCommand(3.0, 4.0, 5.0, 6.0, 7.0, 8.0)
]
assertCommandsEqual(actual, expect)
}
func testRelativeSmoothToAfterMoveTo() {
let actual:[SVGCommand] = SVGPath("M1 2s3 4 5 6").commands
let expect:[SVGCommand] = [
SVGCommand(1.0, 2.0, type: .move),
SVGCommand(1.0, 2.0, 4.0, 6.0, 6.0, 8.0)
]
assertCommandsEqual(actual, expect)
}
func testRelativeSmoothToAfterLineTo() {
let actual:[SVGCommand] = SVGPath("L1 2s3 4 5 6").commands
let expect:[SVGCommand] = [
SVGCommand(1.0, 2.0, type: .line),
SVGCommand(1.0, 2.0, 4.0, 6.0, 6.0, 8.0)
]
assertCommandsEqual(actual, expect)
}
func testRelativeSmoothToAfterQuadCurveTo() {
let actual:[SVGCommand] = SVGPath("Q1 2 3 4s5 6 7 8").commands
let expect:[SVGCommand] = [
SVGCommand(1.0, 2.0, 3.0, 4.0),
SVGCommand(3.0, 4.0, 8.0, 10.0, 10.0, 12.0)
]
assertCommandsEqual(actual, expect)
}
}