Swift Testing for Unit Tests PART 1 (#5119)
* migrated a lot of unit tests to Swift Testing and added a new implementation for deferred fulfillment more tests migration Cleaned the code manually to establish some good patterns more code improvements some more code improvements removed empty tests update project * more pr suggestions and cleanups * removed the TestSetup pattern * fixing claude not reusing tests * pr suggestion + added indent rule to swiftformat so that we can prevent AIs to change that
This commit is contained in:
@@ -8,33 +8,26 @@
|
||||
|
||||
import AVKit
|
||||
@testable import ElementX
|
||||
import XCTest
|
||||
import Testing
|
||||
|
||||
final class AVMetadataMachineReadableCodeObjectExtensionsTest: XCTestCase {
|
||||
func testDecodeQRCodeVersion8() {
|
||||
@Suite
|
||||
struct AVMetadataMachineReadableCodeObjectExtensionsTest {
|
||||
@Test
|
||||
func decodeQRCodeVersion8() throws {
|
||||
// swiftlint:disable:next line_length
|
||||
let rawDataHexString = "4a34d415452495802048bf94b094096e57d3ea43545604cf59b1704879d295cf7fdd99c62df7866da36005668747470733a2f2f73796e617073652d6f6964632e656c656d656e742e6465762f5f73796e617073652f636c69656e742f72656e64657a766f75732f3031485a32394d345936374a4e315658505759464e355a363638002168747470733a2f2f73796e617073652d6f6964632e656c656d656e742e6465762f0ec11ec11ec11ec11ec11ec11ec11ec11ec11ec11ec11ec11ec11ec11ec"
|
||||
// swiftlint:disable:next line_length
|
||||
let expectedDecodedString = "4d415452495802048bf94b094096e57d3ea43545604cf59b1704879d295cf7fdd99c62df7866da36005668747470733a2f2f73796e617073652d6f6964632e656c656d656e742e6465762f5f73796e617073652f636c69656e742f72656e64657a766f75732f3031485a32394d345936374a4e315658505759464e355a363638002168747470733a2f2f73796e617073652d6f6964632e656c656d656e742e6465762f"
|
||||
let symbolVersion = 8
|
||||
|
||||
guard let data = Data(hexString: rawDataHexString) else {
|
||||
XCTFail("Could not initialise the raw data")
|
||||
return
|
||||
}
|
||||
let data = try #require(Data(hexString: rawDataHexString))
|
||||
|
||||
guard let resultData = try? AVMetadataMachineReadableCodeObject.removeQRProtocolData(data, symbolVersion: symbolVersion) else {
|
||||
XCTFail("Could not remove the protocol data")
|
||||
return
|
||||
}
|
||||
let resultData = try #require(try AVMetadataMachineReadableCodeObject.removeQRProtocolData(data, symbolVersion: symbolVersion))
|
||||
|
||||
let resultString = resultData.map { String(format: "%02x", $0) }.joined()
|
||||
XCTAssertEqual(expectedDecodedString, resultString)
|
||||
#expect(expectedDecodedString == resultString)
|
||||
|
||||
guard let expectedResultData = Data(hexString: expectedDecodedString) else {
|
||||
XCTFail("Could not initialise the decoded data")
|
||||
return
|
||||
}
|
||||
XCTAssertEqual(expectedResultData, resultData)
|
||||
let expectedResultData = try #require(Data(hexString: expectedDecodedString))
|
||||
#expect(expectedResultData == resultData)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user