2020-01-22 02:21:23 +00:00
|
|
|
//
|
|
|
|
// AttributedStringHelperTests.swift
|
|
|
|
// TuskerTests
|
|
|
|
//
|
|
|
|
// Created by Shadowfacts on 1/21/20.
|
|
|
|
// Copyright © 2020 Shadowfacts. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import XCTest
|
|
|
|
@testable import Tusker
|
|
|
|
|
|
|
|
class AttributedStringHelperTests: XCTestCase {
|
|
|
|
|
|
|
|
override func setUp() {
|
|
|
|
}
|
|
|
|
|
|
|
|
override func tearDown() {
|
|
|
|
}
|
2024-01-17 20:51:54 +00:00
|
|
|
|
|
|
|
func testTrimLeading() {
|
|
|
|
let a = NSMutableAttributedString(string: " a ")
|
|
|
|
a.trimLeadingCharactersInSet(.whitespaces)
|
|
|
|
XCTAssertEqual(a, NSAttributedString(string: "a "))
|
|
|
|
let b = NSMutableAttributedString(string: " ")
|
|
|
|
b.trimLeadingCharactersInSet(.whitespaces)
|
|
|
|
XCTAssertEqual(b, NSAttributedString(string: ""))
|
|
|
|
let c = NSMutableAttributedString(string: "")
|
|
|
|
c.trimLeadingCharactersInSet(.whitespaces)
|
|
|
|
XCTAssertEqual(c, NSAttributedString(string: ""))
|
|
|
|
let d = NSMutableAttributedString(string: "abc")
|
|
|
|
d.trimLeadingCharactersInSet(.whitespaces)
|
|
|
|
XCTAssertEqual(d, NSAttributedString(string: "abc"))
|
|
|
|
}
|
|
|
|
|
|
|
|
func testTrimTrailing() {
|
|
|
|
let a = NSMutableAttributedString(string: " a ")
|
|
|
|
a.trimTrailingCharactersInSet(.whitespaces)
|
|
|
|
XCTAssertEqual(a, NSAttributedString(string: " a"))
|
|
|
|
let b = NSMutableAttributedString(string: " ")
|
|
|
|
b.trimTrailingCharactersInSet(.whitespaces)
|
|
|
|
XCTAssertEqual(b, NSAttributedString(string: ""))
|
|
|
|
let c = NSMutableAttributedString(string: "")
|
|
|
|
c.trimTrailingCharactersInSet(.whitespaces)
|
|
|
|
XCTAssertEqual(c, NSAttributedString(string: ""))
|
|
|
|
let d = NSMutableAttributedString(string: "abc")
|
|
|
|
d.trimTrailingCharactersInSet(.whitespaces)
|
|
|
|
XCTAssertEqual(d, NSAttributedString(string: "abc"))
|
|
|
|
}
|
2020-01-22 02:21:23 +00:00
|
|
|
|
|
|
|
}
|