-
Notifications
You must be signed in to change notification settings - Fork 749
Expand file tree
/
Copy pathCacheKeyConstructionTests.swift
More file actions
53 lines (39 loc) · 1.74 KB
/
CacheKeyConstructionTests.swift
File metadata and controls
53 lines (39 loc) · 1.74 KB
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
import XCTest
@testable import ApolloSQLite
final class CacheKeyConstructionTests: XCTestCase {
func testCacheKeySplitsPeriods() {
let input = "my.chemical.romance"
let expected = ["my", "chemical", "romance"]
XCTAssertEqual(input.splitIntoCacheKeyComponents(), expected)
}
func testCacheKeySplitsPeriodsButIgnoresParentheses() {
let input = "my.chemical.romance(xWv.CD-RIP.whole-album)"
let expected = ["my", "chemical", "romance(xWv.CD-RIP.whole-album)"]
XCTAssertEqual(input.splitIntoCacheKeyComponents(), expected)
}
func testCacheKeyIgnoresNestedParentheses() {
let input = "my.chemical.romance(the.(very)hidden.albums)"
let expected = ["my", "chemical", "romance(the.(very)hidden.albums)"]
XCTAssertEqual(input.splitIntoCacheKeyComponents(), expected)
}
func testDoubleNestedInput() {
let input = "my.chemical.romance(name:imnotokay.rip(xWv(the.original).HIGH-QUALITY)).mp3"
let expected = ["my", "chemical", "romance(name:imnotokay.rip(xWv(the.original).HIGH-QUALITY))", "mp3"]
XCTAssertEqual(input.splitIntoCacheKeyComponents(), expected)
}
func testUnbalancedInput() {
let input = "my.chemical.romance(name: )(.thebest.)()"
let expected = ["my", "chemical", "romance(name: )(.thebest.)()"]
XCTAssertEqual(input.splitIntoCacheKeyComponents(), expected)
}
func testUnbalancedInputContinued() {
let input = "my.chemical.romance(name: )(.thebest.)().count"
let expected = ["my", "chemical", "romance(name: )(.thebest.)()", "count"]
XCTAssertEqual(input.splitIntoCacheKeyComponents(), expected)
}
func testNoSplits() {
let input = "mychemicalromance"
let expected = ["mychemicalromance"]
XCTAssertEqual(input.splitIntoCacheKeyComponents(), expected)
}
}