From 622532484e8924048d7f45cc7807e579e4460277 Mon Sep 17 00:00:00 2001 From: Ash Vardanian <1983160+ashvardanian@users.noreply.github.com> Date: Thu, 21 Mar 2024 11:03:58 -0600 Subject: [PATCH] Fix: Swift tests passing (#123) Closes #77 --------- Co-authored-by: Riyazul555 --- swift/Test.swift | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/swift/Test.swift b/swift/Test.swift index 908c0c3c..4b839022 100644 --- a/swift/Test.swift +++ b/swift/Test.swift @@ -44,17 +44,21 @@ class StringZillaTests: XCTestCase { XCTAssertEqual(testString[index...], "Hello, world! Welcome to StringZilla. 👋") } - // TODO: This fails! - // func testFindLastCharacterNotFromSet() { - // let index = testString.findLast(characterNotFrom: "aeiou")! - // XCTAssertEqual(testString.distance(from: testString.startIndex, to: index), 38) - // XCTAssertEqual(testString[index...], "👋") - // } + func testFindLastCharacterNotFromSet() { + let index = testString.findLast(characterNotFrom: "aeiou")! + XCTAssertEqual(testString.distance(from: testString.startIndex, to: index), 38) + XCTAssertEqual(testString[index...], "👋") + } func testEditDistance() { let otherString = "Hello, world!" - let distance = try? testString.editDistance(from: otherString) // Using try? + let distance = try? testString.editDistance(from: otherString) XCTAssertNotNil(distance) XCTAssertEqual(distance, 29) } + + func testFindLastCharacterNotFromSetNoMatch() { + let index = "aeiou".findLast(characterNotFrom: "aeiou") + XCTAssertNil(index) + } }