File tree Expand file tree Collapse file tree 3 files changed +51
-2
lines changed Expand file tree Collapse file tree 3 files changed +51
-2
lines changed Original file line number Diff line number Diff line change @@ -53,8 +53,8 @@ extension SystemChar {
5353 internal var isLetter : Bool {
5454 guard isASCII else { return false }
5555 let asciiRaw : UInt8 = numericCast ( rawValue)
56- return ( UInt8 ( ascii: " a " ) ..< UInt8 ( ascii: " z " ) ) . contains ( asciiRaw) ||
57- ( UInt8 ( ascii: " A " ) ..< UInt8 ( ascii: " Z " ) ) . contains ( asciiRaw)
56+ return ( UInt8 ( ascii: " a " ) ... UInt8 ( ascii: " z " ) ) . contains ( asciiRaw) ||
57+ ( UInt8 ( ascii: " A " ) ... UInt8 ( ascii: " Z " ) ) . contains ( asciiRaw)
5858 }
5959}
6060
Original file line number Diff line number Diff line change 1+ /*
2+ This source file is part of the Swift System open source project
3+
4+ Copyright (c) 2020 - 2021 Apple Inc. and the Swift System project authors
5+ Licensed under Apache License v2.0 with Runtime Library Exception
6+
7+ See https://swift.org/LICENSE.txt for license information
8+ */
9+
10+ import XCTest
11+
12+ #if SYSTEM_PACKAGE
13+ @testable import SystemPackage
14+ #else
15+ @testable import System
16+ #endif
17+
18+ final class SystemCharTest : XCTestCase {
19+ func testIsLetter( ) {
20+ let valid = SystemString (
21+ " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ " )
22+ for char in valid {
23+ XCTAssertTrue ( char. isLetter)
24+ }
25+
26+ // non printable
27+ for value in 0 ..< ( UInt8 ( ascii: " " ) ) {
28+ XCTAssertFalse ( SystemChar ( codeUnit: value) . isLetter)
29+ }
30+ XCTAssertFalse ( SystemChar ( codeUnit: 0x7F ) . isLetter) // DEL
31+
32+ // misc other
33+ let invalid = SystemString (
34+ ##" !"#$%&'()*+,-./0123456789:;<=>?@[\]^_`{|}~"## )
35+ for char in invalid {
36+ XCTAssertFalse ( char. isLetter)
37+ }
38+ }
39+ }
Original file line number Diff line number Diff line change @@ -94,6 +94,15 @@ extension MockingTest {
9494 ]
9595}
9696
97+ extension SystemCharTest {
98+ // DO NOT MODIFY: This is autogenerated, use:
99+ // `swift test --generate-linuxmain`
100+ // to regenerate.
101+ static let __allTests__SystemCharTest = [
102+ ( " testIsLetter " , testIsLetter) ,
103+ ]
104+ }
105+
97106extension SystemStringTest {
98107 // DO NOT MODIFY: This is autogenerated, use:
99108 // `swift test --generate-linuxmain`
@@ -115,6 +124,7 @@ public func __allTests() -> [XCTestCaseEntry] {
115124 testCase ( FilePathTest . __allTests__FilePathTest) ,
116125 testCase ( FilePermissionsTest . __allTests__FilePermissionsTest) ,
117126 testCase ( MockingTest . __allTests__MockingTest) ,
127+ testCase ( SystemCharTest . __allTests__SystemCharTest) ,
118128 testCase ( SystemStringTest . __allTests__SystemStringTest) ,
119129 ]
120130}
You can’t perform that action at this time.
0 commit comments