Skip to content
This repository was archived by the owner on Dec 15, 2024. It is now read-only.

Commit

Permalink
updated Unit Tests for Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed May 6, 2016
1 parent 5e17b3a commit 38d1bfe
Showing 1 changed file with 20 additions and 24 deletions.
44 changes: 20 additions & 24 deletions Sources/UnitTests/RegularExpressionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,9 @@ final class RegularExpressionTests: XCTestCase {
guard let match = regex.match(string, options: [])
else { XCTFail("Could not find match"); return }

let stringRange = NSRange(Range(match.range))
let stringRange = NSRange(match.range)

#if os(Linux)
let matchString = NSString(string: string).substringWithRange(stringRange)
#else
let matchString = NSString(string: string).substring(with: stringRange)
#endif
let matchString = NSString(string: string).substring(with: stringRange)

XCTAssert(matchString == "Welcome")
}
Expand All @@ -49,13 +45,9 @@ final class RegularExpressionTests: XCTestCase {
guard let match = regex.match(string, options: [])
else { XCTFail("Could not find match"); return }

let stringRange = NSRange(Range(match.range))
let stringRange = NSRange(match.range)

#if os(Linux)
let matchString = NSString(string: string).substringWithRange(stringRange)
#else
let matchString = NSString(string: string).substring(with: stringRange)
#endif
let matchString = NSString(string: string).substring(with: stringRange)

XCTAssert(matchString == "aaa")
}
Expand All @@ -70,13 +62,9 @@ final class RegularExpressionTests: XCTestCase {
guard let match = regex.match(string, options: [])
else { XCTFail("Could not find match"); return }

let stringRange = NSRange(Range(match.range))
let stringRange = NSRange(match.range)

#if os(Linux)
let matchString = NSString(string: string).substringWithRange(stringRange)
#else
let matchString = NSString(string: string).substring(with: stringRange)
#endif
let matchString = NSString(string: string).substring(with: stringRange)

XCTAssert(matchString == "Bird", matchString)
}
Expand All @@ -91,13 +79,9 @@ final class RegularExpressionTests: XCTestCase {
guard let match = regex.match(string, options: [])
else { XCTFail("Could not find match"); return }

let stringRange = NSRange(Range(match.range))
let stringRange = NSRange(match.range)

#if os(Linux)
let matchString = NSString(string: string).substringWithRange(stringRange)
#else
let matchString = NSString(string: string).substring(with: stringRange)
#endif
let matchString = NSString(string: string).substring(with: stringRange)

// matched whole string
XCTAssert(matchString == string)
Expand Down Expand Up @@ -140,3 +124,15 @@ final class RegularExpressionTests: XCTestCase {
}
}
}

#if os(Linux)

extension NSRange {

init(_ range: Range<Int>) {

self = NSRange(CountableRange(range))
}
}

#endif

0 comments on commit 38d1bfe

Please sign in to comment.