@@ -1289,5 +1289,37 @@ extension TestNSString {
1289
1289
1290
1290
let replaceSuffixWithMultibyte = testString. replacingOccurrences ( of: testSuffix, with: testReplacementEmoji)
1291
1291
XCTAssertEqual ( replaceSuffixWithMultibyte, testPrefix + testEmoji + testReplacementEmoji)
1292
+
1293
+ let str1 = " Hello \r \n world. "
1294
+ XCTAssertEqual ( str1. replacingOccurrences ( of: " \n " , with: " " ) , " Hello \r world. " )
1295
+ XCTAssertEqual ( str1. replacingOccurrences ( of: " \r " , with: " " ) , " Hello \n world. " )
1296
+ XCTAssertEqual ( str1. replacingOccurrences ( of: " \r \n " , with: " " ) , " Hello world. " )
1297
+ XCTAssertEqual ( str1. replacingOccurrences ( of: " \r \n " , with: " \n \r " ) , " Hello \n \r world. " )
1298
+ XCTAssertEqual ( str1. replacingOccurrences ( of: " \r \n " , with: " \r \n " ) , " Hello \r \n world. " )
1299
+ XCTAssertEqual ( str1. replacingOccurrences ( of: " \n \r " , with: " " ) , " Hello \r \n world. " )
1300
+
1301
+ let str2 = " Hello \n \r world. "
1302
+ XCTAssertEqual ( str2. replacingOccurrences ( of: " \n " , with: " " ) , " Hello \r world. " )
1303
+ XCTAssertEqual ( str2. replacingOccurrences ( of: " \r " , with: " " ) , " Hello \n world. " )
1304
+ XCTAssertEqual ( str2. replacingOccurrences ( of: " \r \n " , with: " " ) , " Hello \n \r world. " )
1305
+ XCTAssertEqual ( str2. replacingOccurrences ( of: " \n \r " , with: " " ) , " Hello world. " )
1306
+ XCTAssertEqual ( str2. replacingOccurrences ( of: " \n \r " , with: " \r \n " ) , " Hello \r \n world. " )
1307
+ XCTAssertEqual ( str2. replacingOccurrences ( of: " \n \r " , with: " \n \r " ) , " Hello \n \r world. " )
1308
+
1309
+ let str3 = " Hello \n \n world. "
1310
+ XCTAssertEqual ( str3. replacingOccurrences ( of: " \n " , with: " " ) , " Hello world. " )
1311
+ XCTAssertEqual ( str3. replacingOccurrences ( of: " \r " , with: " " ) , " Hello \n \n world. " )
1312
+ XCTAssertEqual ( str3. replacingOccurrences ( of: " \r \n " , with: " " ) , " Hello \n \n world. " )
1313
+ XCTAssertEqual ( str3. replacingOccurrences ( of: " \r \n " , with: " \n \r " ) , " Hello \n \n world. " )
1314
+ XCTAssertEqual ( str3. replacingOccurrences ( of: " \r \n " , with: " \r \n " ) , " Hello \n \n world. " )
1315
+ XCTAssertEqual ( str3. replacingOccurrences ( of: " \n \r " , with: " " ) , " Hello \n \n world. " )
1316
+
1317
+ let str4 = " Hello \r \r world. "
1318
+ XCTAssertEqual ( str4. replacingOccurrences ( of: " \n " , with: " " ) , " Hello \r \r world. " )
1319
+ XCTAssertEqual ( str4. replacingOccurrences ( of: " \r " , with: " " ) , " Hello world. " )
1320
+ XCTAssertEqual ( str4. replacingOccurrences ( of: " \r \n " , with: " " ) , " Hello \r \r world. " )
1321
+ XCTAssertEqual ( str4. replacingOccurrences ( of: " \r \n " , with: " \n \r " ) , " Hello \r \r world. " )
1322
+ XCTAssertEqual ( str4. replacingOccurrences ( of: " \r \n " , with: " \r \n " ) , " Hello \r \r world. " )
1323
+ XCTAssertEqual ( str4. replacingOccurrences ( of: " \n \r " , with: " " ) , " Hello \r \r world. " )
1292
1324
}
1293
1325
}
0 commit comments