Created
May 21, 2022 21:18
-
-
Save rudifa/c2adff3a396288687f6bced03346c817 to your computer and use it in GitHub Desktop.
BackupFileTests.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
// | |
// BackupFileTests.swift | |
// BackupFileTests | |
// | |
// Created by Rudolf Farkas on 21.05.22. | |
// | |
@testable import BackupFile | |
import XCTest | |
class BackupFileTests: XCTestCase { | |
override func setUpWithError() throws {} | |
override func tearDownWithError() throws {} | |
func test_BackupFile() throws { | |
// a sample struct for use in testing the BackupFile wrapper | |
struct Sample: Codable { | |
let name: String | |
let age: Int | |
} | |
let sample = Sample(name: "Rudolf", age: 42) | |
let backupFile = BackupFile(wrapped: sample) | |
let encoder = JSONEncoder() | |
let data = try encoder.encode(backupFile) | |
let decoder = JSONDecoder() | |
let restoredBackupFile = try decoder.decode(BackupFile<Sample>.self, from: data) | |
XCTAssertEqual(restoredBackupFile.wrapped.name, sample.name) | |
XCTAssertEqual(restoredBackupFile.wrapped.age, sample.age) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment