@testable import CommoniOS
import XCTest
class CommoniOSTests: XCTestCase {
override func setUpWithError() throws {
}
override func tearDownWithError() throws {
}
override func setUp() {
super.setUp()
}
override func tearDown() {
super.tearDown()
}
func testExample() throws {
let a = 1
let b = 1
XCTAssert(a == b)
}
func testRegular() throws {
let matchedArray = Regular.matches(for: "(?<=\\().*(?=\\))", in: "(三四十)" as String)
XCTAssert(matchedArray[0] == "三四十")
}
func testDelay() {
wait(interval: 10) {
let data = NSData(contentsOf: URL(string: "https://www.baidu.com/s?wd=%E4%BB%8A%E6%97%A5%E6%96%B0%E9%B2%9C%E4%BA%8B&tn=SE_Pclogo_6ysd4c7a&sa=ire_dl_gh_logo&rsv_dl=igh_logo_pc")!)
XCTAssertNotNil(data)
}
}
func testPerformanceExample() throws {
self.measure {
}
}
}
extension XCTestCase {
func wait(interval: TimeInterval = 0.1, completion: @escaping (() -> Void)) {
let exp = expectation(description: "")
DispatchQueue.main.asyncAfter(deadline: .now() + interval) {
completion()
exp.fulfill()
}
waitForExpectations(timeout: interval)
}
}