Make 'isUnknown' method more precise
This commit is contained in:
parent
a2edf41d33
commit
e8afd251ed
2 changed files with 8 additions and 4 deletions
|
|
@ -58,7 +58,8 @@ public struct Constants {
|
||||||
}
|
}
|
||||||
|
|
||||||
static func isUnknown(_ string: String) -> Bool {
|
static func isUnknown(_ string: String) -> Bool {
|
||||||
return string.starts(with: UNKNOWN)
|
let components = string.components(separatedBy: " ")
|
||||||
|
return components.count == 2 && components[0] == UNKNOWN && UInt(components[1]) != nil
|
||||||
}
|
}
|
||||||
|
|
||||||
static func unknown(_ number: UInt) -> String {
|
static func unknown(_ number: UInt) -> String {
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,13 @@ class ConstantsTest: XCTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testIsUnknown() {
|
func testIsUnknown() {
|
||||||
XCTAssert(Constants.isUnknown("unknown"))
|
XCTAssert(Constants.isUnknown("unknown 1"))
|
||||||
XCTAssert(Constants.isUnknown("unknown string"))
|
XCTAssert(Constants.isUnknown("unknown 435"))
|
||||||
XCTAssertFalse(Constants.isUnknown("otp"))
|
XCTAssertFalse(Constants.isUnknown("otp"))
|
||||||
XCTAssertFalse(Constants.isUnknown("Unknown"))
|
XCTAssertFalse(Constants.isUnknown("unknown "))
|
||||||
|
XCTAssertFalse(Constants.isUnknown("unknown something"))
|
||||||
|
XCTAssertFalse(Constants.isUnknown("unknown 123 something"))
|
||||||
|
XCTAssertFalse(Constants.isUnknown("Unknown 1"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func testUnknown() {
|
func testUnknown() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue