Hi,
I had not tested on iOS 18.2 yet.
test_TestStr1() works on iOS 18.2, but on a slightly more complex case it does not.
Bellow is another test with a new function test_TestStr3() that works on iOS 17 but not on iOS 18.2.
The results of the tests I made are for the 3 functions bellow are:
iOS 17 - All 3 functions succeed
iOS 18.1.1 - All 3 functions fail
iOS 18.2 - test_TestStr1() passes the tests but the other 2 fail.
import XCTest
final class TestStrings18Tests: XCTestCase {
override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}
func test_TestStr1()
{
let str1 = "_%\u{7}1\u{7}_";
let str2 = "%\u{7}1\u{7}";
let str3 = "X";
let str4 = str1.replacingOccurrences(of: str2, with: str3);
//This should be true
XCTAssertTrue(str4 == "_X_");
}
func test_TestStr2()
{
//For testing that bug in iOS18 still exists
let s1 = "TVAR(6)\u{11}201\"Ã\"\u{11}201\"A\"";
let s2 = s1.components(separatedBy: "\u{11}201");
let t1 = NSString("TVAR(6)\u{11}201\"Ã\"\u{11}201\"A\"") as String;
let t2 = t1.components(separatedBy: "\u{11}201");
XCTAssertTrue(s2.count == t2.count);
let c = s2.count
//This should be True
XCTAssertTrue(s2[0] == t2[0]);
}
func test_TestStr3()
{
let str1 = "€_%\u{7}1\u{7}_€";
let str2 = "%\u{7}1\u{7}";
let str3 = "X";
let str4 = str1.replacingOccurrences(of: str2, with: str3);
//This should be true
XCTAssertTrue(str4 == "€_X_€");
}
}
Topic:
Programming Languages
SubTopic:
Swift