-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove unneeded pending state, more tests
- Loading branch information
1 parent
e49e0c2
commit c8fe131
Showing
5 changed files
with
66 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import XCTest | ||
|
||
import RangeState | ||
|
||
final class RangeValidatorTests: XCTestCase { | ||
typealias StringValidator = RangeValidator<StringContent> | ||
|
||
@MainActor | ||
func testHandleCompletedValidation() { | ||
let content = StringContent(string: "abc") | ||
let validator = StringValidator(content: content) | ||
|
||
let range = NSRange(0..<3) | ||
let contentRange = StringValidator.ContentRange(range, version: content.currentVersion) | ||
|
||
let val1 = validator.beginValidation(of: .all) | ||
|
||
XCTAssertEqual(val1, .needed(contentRange)) | ||
|
||
validator.completeValidation(of: contentRange, with: .success(range)) | ||
|
||
let val2 = validator.beginValidation(of: .all) | ||
|
||
XCTAssertEqual(val2, .none) | ||
} | ||
|
||
@MainActor | ||
func testHandleDuplicateValidation() { | ||
let content = StringContent(string: "abc") | ||
let validator = StringValidator(content: content) | ||
|
||
let range = NSRange(0..<3) | ||
let contentRange = StringValidator.ContentRange(range, version: content.currentVersion) | ||
|
||
let val1 = validator.beginValidation(of: .all) | ||
|
||
XCTAssertEqual(val1, .needed(contentRange)) | ||
|
||
let val2 = validator.beginValidation(of: .all) | ||
|
||
XCTAssertEqual(val2, .none) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters