Skip to content

Commit

Permalink
MIDIKitIO: Migrated unit tests to Swift Testing (#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
orchetect committed Jan 25, 2025
1 parent a69f854 commit fda4a86
Show file tree
Hide file tree
Showing 20 changed files with 2,383 additions and 2,347 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// © 2021-2024 Steffan Andrews • Licensed under MIT License
//

// iOS Simulator XCTest testing does not give enough permissions to allow creating virtual MIDI
// iOS Simulator testing does not give enough permissions to allow creating virtual MIDI
// ports, so skip these tests on iOS targets
#if !targetEnvironment(simulator)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// © 2021-2024 Steffan Andrews • Licensed under MIT License
//

// iOS Simulator XCTest testing does not give enough permissions to allow creating virtual MIDI
// iOS Simulator testing does not give enough permissions to allow creating virtual MIDI
// ports, so skip these tests on iOS targets
#if !targetEnvironment(simulator)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// © 2021-2024 Steffan Andrews • Licensed under MIT License
//

// iOS Simulator XCTest testing does not give enough permissions to allow creating virtual MIDI
// iOS Simulator testing does not give enough permissions to allow creating virtual MIDI
// ports, so skip these tests on iOS targets
#if !targetEnvironment(simulator)

Expand Down
60 changes: 34 additions & 26 deletions Tests/MIDIKitIOTests/MIDIEndpoint/Endpoint Hashable Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,33 @@
#if !os(tvOS) && !os(watchOS)

@testable import MIDIKitIO
import XCTest
import Testing

final class Endpoint_Hashable_Tests: XCTestCase {
func testInputEndpoint1() {
@Suite struct Endpoint_Hashable_Tests {
@Test
func inputEndpoint1() {
let same: Set<MIDIInputEndpoint> = [
.init(from: 123),
.init(from: 123)
]

XCTAssertEqual(same.count, 1)
#expect(same.count == 1)
}

func testInputEndpoint1B() {
@Test
func inputEndpoint1B() {
let same: Set<MIDIInputEndpoint> = [
.init(from: 123),
.init(from: 456)
]

// even with different ref IDs, since these don't actually currently
// exist in the system, their Unique IDs will both be 0 and thus equal
XCTAssertEqual(same.count, 1)
#expect(same.count == 1)
}

func testInputEndpoint2() {
@Test
func inputEndpoint2() {
let same: Set<MIDIInputEndpoint> = [
MIDIInputEndpoint(
ref: 123,
Expand All @@ -45,11 +48,12 @@ final class Endpoint_Hashable_Tests: XCTestCase {
uniqueID: 12_345_678
)
]

XCTAssertEqual(same.count, 1)
#expect(same.count == 1)
}

func testInputEndpoint2Diff() {
@Test
func inputEndpoint2Diff() {
let same: Set<MIDIInputEndpoint> = [
MIDIInputEndpoint(
ref: 123,
Expand All @@ -64,31 +68,34 @@ final class Endpoint_Hashable_Tests: XCTestCase {
uniqueID: 987_654_321
)
]

XCTAssertEqual(same.count, 2)
#expect(same.count == 2)
}

func testOutputEndpoint1() {
@Test
func outputEndpoint1() {
let same: Set<MIDIOutputEndpoint> = [
.init(from: 123),
.init(from: 123)
]

XCTAssertEqual(same.count, 1)
#expect(same.count == 1)
}

func testOutputEndpoint1B() {
@Test
func outputEndpoint1B() {
let same: Set<MIDIOutputEndpoint> = [
.init(from: 123),
.init(from: 456)
]

// even with different ref IDs, since these don't actually currently
// exist in the system, their Unique IDs will both be 0 and thus equal
XCTAssertEqual(same.count, 1)
#expect(same.count == 1)
}

func testOutputEndpoint2() {
@Test
func outputEndpoint2() {
let same: Set<MIDIOutputEndpoint> = [
MIDIOutputEndpoint(
ref: 123,
Expand All @@ -103,11 +110,12 @@ final class Endpoint_Hashable_Tests: XCTestCase {
uniqueID: 12_345_678
)
]

XCTAssertEqual(same.count, 1)
#expect(same.count == 1)
}

func testOutputEndpoint2Diff() {
@Test
func outputEndpoint2Diff() {
let same: Set<MIDIOutputEndpoint> = [
MIDIOutputEndpoint(
ref: 123,
Expand All @@ -122,8 +130,8 @@ final class Endpoint_Hashable_Tests: XCTestCase {
uniqueID: 987_654_321
)
]

XCTAssertEqual(same.count, 2)
#expect(same.count == 2)
}
}

Expand Down
Loading

0 comments on commit fda4a86

Please sign in to comment.