mirror of
https://github.com/mssun/passforios.git
synced 2026-02-27 18:24:03 +01:00
Use their latest releases and fix some violations and issues. # Conflicts: # .github/workflows/linting.yml # .github/workflows/testing.yml
45 lines
1.1 KiB
Swift
45 lines
1.1 KiB
Swift
//
|
|
// String+UtilitiesTest.swift
|
|
// passKitTests
|
|
//
|
|
// Created by Danny Moesch on 30.09.18.
|
|
// Copyright © 2018 Bob Sun. All rights reserved.
|
|
//
|
|
|
|
import XCTest
|
|
|
|
@testable import passKit
|
|
|
|
final class StringUtilitiesTest: XCTestCase {
|
|
func testTrimmed() {
|
|
[
|
|
(" ", ""),
|
|
(" \n\t\r", ""),
|
|
("\t a \n b \t c \r d \n ", "a \n b \t c \r d"),
|
|
].forEach { untrimmed, trimmed in
|
|
XCTAssertEqual(untrimmed.trimmed, trimmed)
|
|
}
|
|
}
|
|
|
|
func testStringByAddingPercentEncodingForRFC3986() {
|
|
[
|
|
("!#$&'()*+,/:;=?@[]^", "%21%23%24%26%27%28%29%2A%2B%2C/%3A%3B%3D%3F%40%5B%5D%5E"),
|
|
("-._~/", "-._~/"),
|
|
("A*b!c", "A%2Ab%21c"),
|
|
].forEach { unencoded, encoded in
|
|
XCTAssertEqual(unencoded.stringByAddingPercentEncodingForRFC3986(), encoded)
|
|
}
|
|
}
|
|
|
|
func testConcatenateAsLines() {
|
|
[
|
|
("a" | "b", "a\nb"),
|
|
("" | "b", "\nb"),
|
|
("a" | "", "a"),
|
|
("" | "", ""),
|
|
].forEach { concatenated, result in
|
|
XCTAssertEqual(concatenated, result)
|
|
}
|
|
}
|
|
}
|