-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c682333
commit 10bb06b
Showing
2 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
Tests/MRZScannerTests/Private/BoundingRectConverterTests.swift
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,38 @@ | ||
// | ||
// BoundingRectConverterTests.swift | ||
// | ||
// | ||
// Created by Roman Mazeev on 01/12/2023. | ||
// | ||
|
||
@testable import MRZScanner | ||
import XCTest | ||
|
||
final class BoundingRectConverterTests: XCTestCase { | ||
func testConverterEmpty() { | ||
let result = BoundingRectConverter.liveValue.convert([], []) | ||
XCTAssert(result.valid.isEmpty) | ||
XCTAssert(result.invalid.isEmpty) | ||
} | ||
|
||
func testConverter() { | ||
let firstResult = TextRecognizer.Result(results: ["test"], boundingRect: .init(x: 0, y: 0, width: 20, height: 20)) | ||
let secondResult = TextRecognizer.Result(results: ["test"], boundingRect: .zero) | ||
let thirdResult = TextRecognizer.Result(results: ["test"], boundingRect: .init(x: 1, y: 1, width: 40, height: 60)) | ||
|
||
let result = BoundingRectConverter.liveValue.convert( | ||
[ | ||
firstResult, | ||
secondResult, | ||
thirdResult | ||
], | ||
[ | ||
Validator.Result(result: "test", index: 0), | ||
Validator.Result(result: "test", index: 1), | ||
Validator.Result(result: "test", index: 1) | ||
] | ||
) | ||
XCTAssertEqual(result.valid, [firstResult.boundingRect, secondResult.boundingRect]) | ||
XCTAssertEqual(result.invalid, [thirdResult.boundingRect]) | ||
} | ||
} |
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