Tusker/TuskerTests/AttributedStringHelperTests...

47 lines
1.6 KiB
Swift
Raw Permalink Normal View History

//
// 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() {
}
func testCollapsingWhitespace() {
var str = NSAttributedString(string: "test 1\n")
XCTAssertEqual(str.collapsingWhitespace(), NSAttributedString(string: "test 1\n"))
str = NSAttributedString(string: "test 2 \n")
XCTAssertEqual(str.collapsingWhitespace(), NSAttributedString(string: "test 2\n"))
str = NSAttributedString(string: "test 3\n ")
XCTAssertEqual(str.collapsingWhitespace(), NSAttributedString(string: "test 3\n"))
str = NSAttributedString(string: "test 4 \n ")
XCTAssertEqual(str.collapsingWhitespace(), NSAttributedString(string: "test 4\n"))
str = NSAttributedString(string: "test 5 \n blah")
XCTAssertEqual(str.collapsingWhitespace(), NSAttributedString(string: "test 5\nblah"))
str = NSAttributedString(string: "\ntest 6")
XCTAssertEqual(str.collapsingWhitespace(), NSAttributedString(string: "\ntest 6"))
str = NSAttributedString(string: " \ntest 7")
XCTAssertEqual(str.collapsingWhitespace(), NSAttributedString(string: "\ntest 7"))
str = NSAttributedString(string: " \n test 8")
XCTAssertEqual(str.collapsingWhitespace(), NSAttributedString(string: "\ntest 8"))
}
}