forked from mac-cain13/R.swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainTests.swift
61 lines (54 loc) · 1.62 KB
/
MainTests.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
//
// MainTests.swift
// R.swift
//
// Created by Mathijs Kadijk on 28-09-15.
// From: https://github.com/mac-cain13/R.swift
// License: MIT License
//
import XCTest
@testable import RswiftCore
class MainTests: XCTestCase {
override func setUp() {
super.setUp()
}
override func tearDown() {
super.tearDown()
}
let swiftNameData = [
"easy": "easy",
"easyAndSimple": "easyAndSimple",
"easy with some spaces": "easyWithSomeSpaces",
"(looks) easy": "looksEasy",
"looks-easy": "looksEasy",
"looks+like^some-kind*of%easy": "looksLikeSomeKindOfEasy",
"(looks) easy, but it's not really NeXT that easy!": "looksEasyButItSNotReallyNeXTThatEasy",
"easy 123 and done...": "easy123AndDone",
"123 easy!": "easy",
"123 456easy": "easy",
"123 😄": "😄",
"🇳🇱": "🇳🇱",
"🌂MakeItRain!": "🌂MakeItRain",
"PRFXMyClass": "prfxMyClass",
"NSSomeThing": "nsSomeThing",
"MyClass": "myClass",
"PRFX_MyClass": "prfx_MyClass",
"PRFX-myClass": "prfxMyClass",
"123NSSomeThing": "nsSomeThing",
"PR123FXMyClass": "pr123FXMyClass"
]
func testSwiftNameSanitization() {
swiftNameData.forEach {
let sanitizedResult = SwiftIdentifier(name: $0.0, lowercaseStartingCharacters: true).description
XCTAssertEqual(sanitizedResult, $0.1)
}
}
func testPerformanceSwiftNameSanitization() {
// This is an example of a performance test case.
self.measure {
(0...1000).forEach { _ in
let _ = SwiftIdentifier(name: "(looks) easy, but it's not reallY that easy!", lowercaseStartingCharacters: true)
}
}
}
}