Skip to content

Commit

Permalink
Merge pull request #1590 from shogo4405/feature/migration-swift-testing
Browse files Browse the repository at this point in the history
Migration SwiftTesting.
  • Loading branch information
shogo4405 authored Oct 4, 2024
2 parents 525a246 + 3d73800 commit a15468c
Show file tree
Hide file tree
Showing 38 changed files with 344 additions and 352 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Select Xcode version
run: sudo xcode-select -s '/Applications/Xcode_15.4.app'
run: sudo xcode-select -s '/Applications/Xcode_16.app'
- name: bundle install
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ open HaishinKit.xcodeproj
### Development
|Version|Xcode|Swift|
|:----:|:----:|:----:|
|2.0.0+|15.4+|5.10+|
|2.0.0+|16.0+|5.10+|
|1.9.0+|15.4+|5.10+|

### OS
Expand Down
22 changes: 11 additions & 11 deletions Tests/Codec/AudioCodecTests.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import Foundation
import XCTest
import Testing
import AVFoundation

@testable import HaishinKit

final class AudioCodecTests: XCTestCase {
func testEncoderCMSampleBuffer44100_1024() {
@Suite struct AudioCodecTests {
@Test func encoderCMSampleBuffer44100_1024() {
let encoder = HaishinKit.AudioCodec()
encoder.startRunning()
for _ in 0..<10 {
Expand All @@ -15,7 +15,7 @@ final class AudioCodecTests: XCTestCase {
}
}

func testEncoderCMSampleBuffer48000_1024() {
@Test func encoderCMSampleBuffer48000_1024() {
let encoder = HaishinKit.AudioCodec()
encoder.startRunning()
for _ in 0..<10 {
Expand All @@ -25,7 +25,7 @@ final class AudioCodecTests: XCTestCase {
}
}

func testEncoderCMSampleBuffer24000_1024() {
@Test func encoderCMSampleBuffer24000_1024() {
let encoder = HaishinKit.AudioCodec()
encoder.startRunning()
for _ in 0..<10 {
Expand All @@ -35,7 +35,7 @@ final class AudioCodecTests: XCTestCase {
}
}

func testEncoderCMSampleBuffer16000_1024() {
@Test func encoderCMSampleBuffer16000_1024() {
let encoder = HaishinKit.AudioCodec()
encoder.startRunning()
for _ in 0..<10 {
Expand All @@ -45,7 +45,7 @@ final class AudioCodecTests: XCTestCase {
}
}

func testEncoderCMSampleBuffer8000_256() {
@Test func encoderCMSampleBuffer8000_256() {
let encoder = HaishinKit.AudioCodec()
encoder.startRunning()
for _ in 0..<10 {
Expand All @@ -55,7 +55,7 @@ final class AudioCodecTests: XCTestCase {
}
}

func testEncoderCMSampleBuffer8000_960() {
@Test func encoderCMSampleBuffer8000_960() {
let encoder = HaishinKit.AudioCodec()
encoder.startRunning()
for _ in 0..<10 {
Expand All @@ -65,7 +65,7 @@ final class AudioCodecTests: XCTestCase {
}
}

func testEncoderCMSampleBuffer8000_1224() {
@Test func encoderCMSampleBuffer8000_1224() {
let encoder = HaishinKit.AudioCodec()
encoder.startRunning()
for _ in 0..<10 {
Expand All @@ -75,7 +75,7 @@ final class AudioCodecTests: XCTestCase {
}
}

func testEncoderCMSampleBuffer8000_numSamples() {
@Test func encoderCMSampleBuffer8000_numSamples() {
let numSamples: [Int] = [1024, 1024, 1028, 1024, 1028, 1028, 962, 962, 960, 2237, 2236]
let encoder = HaishinKit.AudioCodec()
encoder.startRunning()
Expand All @@ -86,7 +86,7 @@ final class AudioCodecTests: XCTestCase {
}
}

func test3Channel_withoutCrash() {
@Test func test3Channel_withoutCrash() {
let encoder = HaishinKit.AudioCodec()
encoder.startRunning()
if let sampleBuffer = CMAudioSampleBufferFactory.makeSilence(44100, numSamples: 256, channels: 3) {
Expand Down
12 changes: 6 additions & 6 deletions Tests/Extension/CMSampleBuffer+ExtensionTests.swift
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import Foundation
import XCTest
import Testing
import CoreMedia

@testable import HaishinKit

final class CMSampleBufferExtensionTests: XCTestCase {
func testIsNotSync() {
@Suite struct CMSampleBufferExtensionTests {
@Test func isNotSync() {
if let video1 = CMVideoSampleBufferFactory.makeSampleBuffer(width: 100, height: 100) {
video1.sampleAttachments[0][.notSync] = 1
} else {
XCTFail()
Issue.record()
}

if let video2 = CMVideoSampleBufferFactory.makeSampleBuffer(width: 100, height: 100) {
XCTAssertFalse(video2.isNotSync)
#expect(!video2.isNotSync)
} else {
XCTFail()
Issue.record()
}
}
}
36 changes: 18 additions & 18 deletions Tests/Extension/ExpressibleByIntegerLiteral+ExtensionTests.swift
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import Foundation
import XCTest
import Testing

@testable import HaishinKit

final class ExpressibleByIntegerLiteralTests: XCTestCase {
func testInt32() {
XCTAssertEqual(Int32.min.bigEndian.data, Data([128, 0, 0, 0]))
XCTAssertEqual(Int32(32).bigEndian.data, Data([0, 0, 0, 32]))
XCTAssertEqual(Int32.max.bigEndian.data, Data([127, 255, 255, 255]))
@Suite struct ExpressibleByIntegerLiteralTests {
@Test func int32() {
#expect(Int32.min.bigEndian.data == Data([128, 0, 0, 0]))
#expect(Int32(32).bigEndian.data == Data([0, 0, 0, 32]))
#expect(Int32.max.bigEndian.data == Data([127, 255, 255, 255]))
}

func testUInt32() {
XCTAssertEqual(UInt32.min.bigEndian.data, Data([0, 0, 0, 0]))
XCTAssertEqual(UInt32(32).bigEndian.data, Data([0, 0, 0, 32]))
XCTAssertEqual(UInt32.max.bigEndian.data, Data([255, 255, 255, 255]))
@Test func uInt32() {
#expect(UInt32.min.bigEndian.data == Data([0, 0, 0, 0]))
#expect(UInt32(32).bigEndian.data == Data([0, 0, 0, 32]))
#expect(UInt32.max.bigEndian.data == Data([255, 255, 255, 255]))
}

func testInt64() {
XCTAssertEqual(Int64.min.bigEndian.data, Data([128, 0, 0, 0, 0, 0, 0, 0]))
XCTAssertEqual(Int64(32).bigEndian.data, Data([0, 0, 0, 0, 0, 0, 0, 32]))
XCTAssertEqual(Int64.max.bigEndian.data, Data([127,255,255, 255, 255, 255, 255, 255]))
@Test func int64() {
#expect(Int64.min.bigEndian.data == Data([128, 0, 0, 0, 0, 0, 0, 0]))
#expect(Int64(32).bigEndian.data == Data([0, 0, 0, 0, 0, 0, 0, 32]))
#expect(Int64.max.bigEndian.data == Data([127,255,255, 255, 255, 255, 255, 255]))
}

func testUInt64() {
XCTAssertEqual(UInt64.min.bigEndian.data, Data([0, 0, 0, 0, 0, 0, 0, 0]))
XCTAssertEqual(UInt64(32).bigEndian.data, Data([0, 0, 0, 0, 0, 0, 0, 32]))
XCTAssertEqual(UInt64.max.bigEndian.data, Data([255, 255, 255, 255, 255, 255, 255, 255]))
@Test func uInt64() {
#expect(UInt64.min.bigEndian.data == Data([0, 0, 0, 0, 0, 0, 0, 0]))
#expect(UInt64(32).bigEndian.data == Data([0, 0, 0, 0, 0, 0, 0, 32]))
#expect(UInt64.max.bigEndian.data == Data([255, 255, 255, 255, 255, 255, 255, 255]))
}
}
10 changes: 5 additions & 5 deletions Tests/Extension/Foundation+ExtensionTests.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import Foundation
import XCTest
import Testing

@testable import HaishinKit

final class FoundationExtensionTest: XCTestCase {
func testNSURL() {
@Suite struct FoundationExtensionTest {
@Test func nSURL() {
let url = URL(string: "http://localhost/foo/bar?hello=world!!&foo=bar")!
let dictionary: [String: String] = url.dictionaryFromQuery()
XCTAssertEqual(dictionary["hello"], "world!!")
XCTAssertEqual(dictionary["foo"], "bar")
#expect(dictionary["hello"] == "world!!")
#expect(dictionary["foo"] == "bar")
}
}
10 changes: 5 additions & 5 deletions Tests/Extension/SwiftCore+ExtensionTests.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import Foundation
import XCTest
import Testing

@testable import HaishinKit

final class SwiftCoreExtensionTests: XCTestCase {
func testInt32() {
XCTAssertEqual(Int32.min, Int32(data: Int32.min.data))
XCTAssertEqual(Int32.max, Int32(data: Int32.max.data))
@Suite struct SwiftCoreExtensionTests {
@Test func int32() {
#expect(Int32.min == Int32(data: Int32.min.data))
#expect(Int32.max == Int32(data: Int32.max.data))
}
}
6 changes: 3 additions & 3 deletions Tests/ISO/ADTSHeaderTests.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Foundation
import XCTest
import Testing

@testable import HaishinKit

final class ADTSHeaderTests: XCTestCase {
func testBytes() {
@Suite struct ADTSHeaderTests {
@Test func bytes() {
let data = Data([255, 241, 77, 128, 112, 127, 252, 1])
let _ = ADTSHeader(data: data)
}
Expand Down
Loading

0 comments on commit a15468c

Please sign in to comment.