-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from BastiaanJansen/dev
Unit test for queue
- Loading branch information
Showing
6 changed files
with
104 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
xcuserdata/ | ||
DerivedData/ | ||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata | ||
.swiftpm |
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,8 @@ | ||
// | ||
// File.swift | ||
// Toast | ||
// | ||
// Created by Bas Jansen on 16/09/2023. | ||
// | ||
|
||
import Foundation |
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,36 @@ | ||
// | ||
// ToastQueueTest.swift | ||
// | ||
// | ||
// Created by Bas Jansen on 16/09/2023. | ||
// | ||
|
||
import XCTest | ||
@testable import Toast | ||
|
||
final class ToastQueueTest: XCTestCase { | ||
|
||
override func setUpWithError() throws { | ||
// Put setup code here. This method is called before the invocation of each test method in the class. | ||
} | ||
|
||
override func tearDownWithError() throws { | ||
// Put teardown code here. This method is called after the invocation of each test method in the class. | ||
} | ||
|
||
func testExample() throws { | ||
// This is an example of a functional test case. | ||
// Use XCTAssert and related functions to verify your tests produce the correct results. | ||
// Any test you write for XCTest can be annotated as throws and async. | ||
// Mark your test throws to produce an unexpected failure when your test encounters an uncaught error. | ||
// Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards. | ||
} | ||
|
||
func testPerformanceExample() throws { | ||
// This is an example of a performance test case. | ||
self.measure { | ||
// Put the code you want to measure the time of here. | ||
} | ||
} | ||
|
||
} |
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,41 @@ | ||
// | ||
// ToastQueuetest.swift | ||
// | ||
// | ||
// Created by Bas Jansen on 16/09/2023. | ||
// | ||
|
||
import XCTest | ||
@testable import Toast | ||
|
||
final class ToastQueueTest: XCTestCase { | ||
|
||
private var queue: ToastQueue! | ||
|
||
override func setUpWithError() throws { | ||
queue = ToastQueue() | ||
} | ||
|
||
override func tearDownWithError() throws { | ||
|
||
} | ||
|
||
func test_whenEnqueuingToast_sizeIsOne() throws { | ||
let toast = Toast.text("Toast") | ||
|
||
queue.enqueue(toast) | ||
|
||
XCTAssertEqual(queue.size(), 1) | ||
} | ||
|
||
func test_whenEnqueuingMultipleToasts_sizeIsThree() throws { | ||
let toast = Toast.text("Toast") | ||
let toast2 = Toast.text("Toast") | ||
let toast3 = Toast.text("Toast") | ||
|
||
queue.enqueue([toast, toast2, toast3]) | ||
|
||
XCTAssertEqual(queue.size(), 3) | ||
} | ||
|
||
} |