Skip to content

Commit 58f1b73

Browse files
authored
Merge pull request swiftlang#1492 from milseman/test_redundancy_test
[test] Drop stdlib-redundant tests
2 parents 04b903a + bb788a2 commit 58f1b73

File tree

1 file changed

+0
-220
lines changed

1 file changed

+0
-220
lines changed

TestFoundation/TestNSString.swift

Lines changed: 0 additions & 220 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ class TestNSString : XCTestCase {
9595
("test_ExternalRepresentation", test_ExternalRepresentation),
9696
("test_mutableStringConstructor", test_mutableStringConstructor),
9797
("test_emptyStringPrefixAndSuffix",test_emptyStringPrefixAndSuffix),
98-
("test_PrefixSuffix", test_PrefixSuffix),
9998
("test_reflection", { _ in test_reflection }),
10099
("test_replacingOccurrences", test_replacingOccurrences),
101100
("test_getLineStart", test_getLineStart),
@@ -1210,225 +1209,6 @@ class TestNSString : XCTestCase {
12101209
}
12111210
}
12121211

1213-
struct ComparisonTest {
1214-
enum TestBehavior {
1215-
case run
1216-
case expectedFailure(String)
1217-
case skip(String)
1218-
}
1219-
let lhs: String
1220-
let rhs: String
1221-
let loc: UInt
1222-
let behavior: TestBehavior
1223-
1224-
var expectedFailure: Bool {
1225-
if case .expectedFailure = behavior {
1226-
return true
1227-
} else {
1228-
return false
1229-
}
1230-
}
1231-
1232-
init(
1233-
_ lhs: String, _ rhs: String,
1234-
expectedFailure xfailReason: String = "",
1235-
skip skipReason: String = "",
1236-
line: UInt = #line
1237-
) {
1238-
self.lhs = lhs
1239-
self.rhs = rhs
1240-
self.loc = line
1241-
1242-
switch (xfailReason.isEmpty, skipReason.isEmpty) {
1243-
case (false, true):
1244-
behavior = .expectedFailure(xfailReason)
1245-
case (_, false):
1246-
behavior = .skip(skipReason)
1247-
default:
1248-
behavior = .run
1249-
}
1250-
}
1251-
}
1252-
1253-
let comparisonTests: [ComparisonTest] = [
1254-
ComparisonTest("", ""),
1255-
ComparisonTest("", "a"),
1256-
1257-
// ASCII cases
1258-
ComparisonTest("t", "tt"),
1259-
ComparisonTest("t", "Tt"),
1260-
ComparisonTest("\u{0}", "",
1261-
skip: "rdar://problem/37686816"),
1262-
ComparisonTest("\u{0}", "\u{0}",
1263-
expectedFailure: "https://bugs.swift.org/browse/SR-332"),
1264-
ComparisonTest("\r\n", "t"),
1265-
ComparisonTest("\r\n", "\n",
1266-
expectedFailure: "blocked on rdar://problem/19036555"),
1267-
ComparisonTest("\u{0}", "\u{0}\u{0}",
1268-
expectedFailure: "rdar://problem/19034601"),
1269-
1270-
// Whitespace
1271-
// U+000A LINE FEED (LF)
1272-
// U+000B LINE TABULATION
1273-
// U+000C FORM FEED (FF)
1274-
// U+0085 NEXT LINE (NEL)
1275-
// U+2028 LINE SEPARATOR
1276-
// U+2029 PARAGRAPH SEPARATOR
1277-
ComparisonTest("\u{0085}", "\n"),
1278-
ComparisonTest("\u{000b}", "\n"),
1279-
ComparisonTest("\u{000c}", "\n"),
1280-
ComparisonTest("\u{2028}", "\n"),
1281-
ComparisonTest("\u{2029}", "\n"),
1282-
ComparisonTest("\r\n\r\n", "\r\n"),
1283-
1284-
// U+0301 COMBINING ACUTE ACCENT
1285-
// U+00E1 LATIN SMALL LETTER A WITH ACUTE
1286-
ComparisonTest("a\u{301}", "\u{e1}"),
1287-
ComparisonTest("a", "a\u{301}"),
1288-
ComparisonTest("a", "\u{e1}"),
1289-
1290-
// U+304B HIRAGANA LETTER KA
1291-
// U+304C HIRAGANA LETTER GA
1292-
// U+3099 COMBINING KATAKANA-HIRAGANA VOICED SOUND MARK
1293-
ComparisonTest("\u{304b}", "\u{304b}"),
1294-
ComparisonTest("\u{304c}", "\u{304c}"),
1295-
ComparisonTest("\u{304b}", "\u{304c}"),
1296-
ComparisonTest("\u{304b}", "\u{304c}\u{3099}"),
1297-
ComparisonTest("\u{304c}", "\u{304b}\u{3099}"),
1298-
ComparisonTest("\u{304c}", "\u{304c}\u{3099}"),
1299-
1300-
// U+212B ANGSTROM SIGN
1301-
// U+030A COMBINING RING ABOVE
1302-
// U+00C5 LATIN CAPITAL LETTER A WITH RING ABOVE
1303-
ComparisonTest("\u{212b}", "A\u{30a}"),
1304-
ComparisonTest("\u{212b}", "\u{c5}"),
1305-
ComparisonTest("A\u{30a}", "\u{c5}"),
1306-
ComparisonTest("A\u{30a}", "a"),
1307-
ComparisonTest("A", "A\u{30a}"),
1308-
1309-
// U+2126 OHM SIGN
1310-
// U+03A9 GREEK CAPITAL LETTER OMEGA
1311-
ComparisonTest("\u{2126}", "\u{03a9}"),
1312-
1313-
// U+0323 COMBINING DOT BELOW
1314-
// U+0307 COMBINING DOT ABOVE
1315-
// U+1E63 LATIN SMALL LETTER S WITH DOT BELOW
1316-
// U+1E69 LATIN SMALL LETTER S WITH DOT BELOW AND DOT ABOVE
1317-
ComparisonTest("\u{1e69}", "s\u{323}\u{307}"),
1318-
ComparisonTest("\u{1e69}", "s\u{307}\u{323}"),
1319-
ComparisonTest("\u{1e69}", "\u{1e63}\u{307}"),
1320-
ComparisonTest("\u{1e63}", "s\u{323}"),
1321-
ComparisonTest("\u{1e63}\u{307}", "s\u{323}\u{307}"),
1322-
ComparisonTest("\u{1e63}\u{307}", "s\u{307}\u{323}"),
1323-
ComparisonTest("s\u{323}", "\u{1e69}"),
1324-
1325-
// U+FB01 LATIN SMALL LIGATURE FI
1326-
ComparisonTest("\u{fb01}", "\u{fb01}"),
1327-
ComparisonTest("fi", "\u{fb01}"),
1328-
1329-
// U+1F1E7 REGIONAL INDICATOR SYMBOL LETTER B
1330-
// \u{1F1E7}\u{1F1E7} Flag of Barbados
1331-
ComparisonTest("\u{1F1E7}", "\u{1F1E7}\u{1F1E7}"),
1332-
1333-
// Test that Unicode collation is performed in deterministic mode.
1334-
//
1335-
// U+0301 COMBINING ACUTE ACCENT
1336-
// U+0341 COMBINING ACUTE TONE MARK
1337-
// U+0954 DEVANAGARI ACUTE ACCENT
1338-
//
1339-
// Collation elements from DUCET:
1340-
// 0301 ; [.0000.0024.0002] # COMBINING ACUTE ACCENT
1341-
// 0341 ; [.0000.0024.0002] # COMBINING ACUTE TONE MARK
1342-
// 0954 ; [.0000.0024.0002] # DEVANAGARI ACUTE ACCENT
1343-
//
1344-
// U+0301 and U+0954 don't decompose in the canonical decomposition mapping.
1345-
// U+0341 has a canonical decomposition mapping of U+0301.
1346-
ComparisonTest("\u{0301}", "\u{0341}"),
1347-
ComparisonTest("\u{0301}", "\u{0954}"),
1348-
ComparisonTest("\u{0341}", "\u{0954}"),
1349-
]
1350-
1351-
enum Stack: Swift.Error {
1352-
case Stack([UInt])
1353-
}
1354-
1355-
func checkHasPrefixHasSuffix(_ lhs: String, _ rhs: String, _ stack: [UInt]) -> Int {
1356-
if (lhs == "" && rhs == "") {
1357-
var failures = 0
1358-
failures += lhs.hasPrefix(rhs) ? 0: 1
1359-
failures += lhs.hasSuffix(rhs) ? 0: 1
1360-
return failures
1361-
} else if lhs == "" {
1362-
var failures = 0
1363-
failures += lhs.hasPrefix(rhs) ? 1 : 0
1364-
failures += lhs.hasSuffix(rhs) ? 1 : 0
1365-
return failures
1366-
} else if rhs == "" {
1367-
var failures = 0
1368-
failures += lhs.hasPrefix(rhs) ? 0 : 1
1369-
failures += lhs.hasSuffix(rhs) ? 0 : 1
1370-
return failures
1371-
}
1372-
1373-
// To determine the expected results, compare grapheme clusters,
1374-
// scalar-to-scalar, of the NFD form of the strings.
1375-
let lhsNFDGraphemeClusters =
1376-
lhs.decomposedStringWithCanonicalMapping.map {
1377-
Array(String($0).unicodeScalars)
1378-
}
1379-
let rhsNFDGraphemeClusters =
1380-
rhs.decomposedStringWithCanonicalMapping.map {
1381-
Array(String($0).unicodeScalars)
1382-
}
1383-
let expectHasPrefix = lhsNFDGraphemeClusters.starts(
1384-
with: rhsNFDGraphemeClusters, by: (==))
1385-
let expectHasSuffix =
1386-
lhsNFDGraphemeClusters.lazy.reversed().starts(
1387-
with: rhsNFDGraphemeClusters.lazy.reversed(), by: (==))
1388-
1389-
func testFailure(_ lhs: Bool, _ rhs: Bool, _ stack: [UInt]) -> Int {
1390-
guard lhs == rhs else {
1391-
// print(stack)
1392-
return 1
1393-
}
1394-
return 0
1395-
}
1396-
1397-
var failures = 0
1398-
failures += testFailure(expectHasPrefix, lhs.hasPrefix(rhs), stack + [#line])
1399-
failures += testFailure(expectHasSuffix, lhs.hasSuffix(rhs), stack + [#line])
1400-
return failures
1401-
}
1402-
1403-
extension TestNSString {
1404-
func test_PrefixSuffix() {
1405-
for test in comparisonTests {
1406-
if case .skip = test.behavior {
1407-
continue
1408-
}
1409-
1410-
var failures = 0
1411-
failures += checkHasPrefixHasSuffix(test.lhs, test.rhs, [test.loc, #line])
1412-
failures += checkHasPrefixHasSuffix(test.rhs, test.lhs, [test.loc, #line])
1413-
1414-
let fragment = "abc"
1415-
let combiner = "\u{0301}"
1416-
1417-
failures += checkHasPrefixHasSuffix(test.lhs + fragment, test.rhs, [test.loc, #line])
1418-
failures += checkHasPrefixHasSuffix(fragment + test.lhs, test.rhs, [test.loc, #line])
1419-
failures += checkHasPrefixHasSuffix(test.lhs + combiner, test.rhs, [test.loc, #line])
1420-
failures += checkHasPrefixHasSuffix(combiner + test.lhs, test.rhs, [test.loc, #line])
1421-
1422-
let fail = (failures > 0)
1423-
if fail {
1424-
// print("Prefix/Suffix case \(test.loc): \(failures) failures")
1425-
// print("Failures were\(test.expectedFailure ? "" : " not") expected")
1426-
}
1427-
XCTAssert(test.expectedFailure == fail, "Unexpected \(test.expectedFailure ?"success":"failure"): \(test.loc)")
1428-
}
1429-
}
1430-
}
1431-
14321212
func test_reflection() {
14331213
}
14341214

0 commit comments

Comments
 (0)