-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathLineToTests.swift
101 lines (84 loc) · 3.03 KB
/
LineToTests.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
//
// LineToTests.swift
// SVGPath
//
// Created by Tim Wood on 1/22/15.
// Copyright (c) 2015 Tim Wood. All rights reserved.
//
import XCTest
import SVGPath
class LineToTests: XCTestCase {
func testSingleMoveTo() {
let actual:[SVGCommand] = SVGPath("L1 2").commands
let expect:[SVGCommand] = [
SVGCommand(1.0, 2.0, type: .line)
]
assertCommandsEqual(actual, expect)
}
func testMultipleMoveToSameCommand() {
let actual:[SVGCommand] = SVGPath("L1 2 3 4").commands
let expect:[SVGCommand] = [
SVGCommand(1.0, 2.0, type: .line),
SVGCommand(3.0, 4.0, type: .line)
]
assertCommandsEqual(actual, expect)
}
func testMultipleMoveToNewCommands() {
let actual:[SVGCommand] = SVGPath("L1 2L3 4").commands
let expect:[SVGCommand] = [
SVGCommand(1.0, 2.0, type: .line),
SVGCommand(3.0, 4.0, type: .line)
]
assertCommandsEqual(actual, expect)
}
func testMultipleMoveToRelative() {
let actual:[SVGCommand] = SVGPath("L1 2l1 2l5 6 1 1").commands
let expect:[SVGCommand] = [
SVGCommand(1.0, 2.0, type: .line),
SVGCommand(2.0, 4.0, type: .line),
SVGCommand(7.0, 10.0, type: .line),
SVGCommand(8.0, 11.0, type: .line)
]
assertCommandsEqual(actual, expect)
}
func testHorizontalLineToAbsolute () {
let actual:[SVGCommand] = SVGPath("M1 2H4H-2 6").commands
let expect:[SVGCommand] = [
SVGCommand( 1.0, 2.0, type: .move),
SVGCommand( 4.0, 2.0, type: .line),
SVGCommand(-2.0, 2.0, type: .line),
SVGCommand( 6.0, 2.0, type: .line)
]
assertCommandsEqual(actual, expect)
}
func testHorizontalLineToRelative () {
let actual:[SVGCommand] = SVGPath("M1 2h4h-2 6").commands
let expect:[SVGCommand] = [
SVGCommand(1.0, 2.0, type: .move),
SVGCommand(5.0, 2.0, type: .line),
SVGCommand(3.0, 2.0, type: .line),
SVGCommand(9.0, 2.0, type: .line)
]
assertCommandsEqual(actual, expect)
}
func testVerticalLineToAbsolute () {
let actual:[SVGCommand] = SVGPath("M1 2V4V-2 6").commands
let expect:[SVGCommand] = [
SVGCommand(1.0, 2.0, type: .move),
SVGCommand(1.0, 4.0, type: .line),
SVGCommand(1.0, -2.0, type: .line),
SVGCommand(1.0, 6.0, type: .line)
]
assertCommandsEqual(actual, expect)
}
func testVerticalLineToRelative () {
let actual:[SVGCommand] = SVGPath("M1 2v4v-2 6").commands
let expect:[SVGCommand] = [
SVGCommand(1.0, 2.0, type: .move),
SVGCommand(1.0, 6.0, type: .line),
SVGCommand(1.0, 4.0, type: .line),
SVGCommand(1.0, 10.0, type: .line)
]
assertCommandsEqual(actual, expect)
}
}