Skip to content

Commit 51fbd19

Browse files
committed
Added unit test
1 parent 4cd58b1 commit 51fbd19

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//
2+
// AVFoundation Utils Tests.swift
3+
// TimecodeKit • https://github.com/orchetect/TimecodeKit
4+
// © 2023 Steffan Andrews • Licensed under MIT License
5+
//
6+
7+
// AVAssetReader is unavailable on watchOS so we can't support any AVAsset operations
8+
#if shouldTestCurrentPlatform && canImport(AVFoundation) && !os(watchOS)
9+
10+
import XCTest
11+
@testable import TimecodeKit
12+
import AVFoundation
13+
14+
class AVFoundationUtils_Tests: XCTestCase {
15+
override func setUp() { }
16+
override func tearDown() { }
17+
18+
func testCMTimeRange_timecodeRange() throws {
19+
let s10 = CMTime(seconds: 10, preferredTimescale: 600)
20+
let s9 = CMTime(seconds: 9, preferredTimescale: 600)
21+
22+
// valid
23+
24+
XCTAssertEqual(
25+
try CMTimeRange(start: s10, end: s10).timecodeRange(at: ._30),
26+
try Timecode(TCC(s: 10), at: ._30) ... Timecode(TCC(s: 10), at: ._30)
27+
)
28+
29+
XCTAssertEqual(
30+
try CMTimeRange(start: s10, duration: s10).timecodeRange(at: ._30),
31+
try Timecode(TCC(s: 10), at: ._30) ... Timecode(TCC(s: 20), at: ._30)
32+
)
33+
34+
// invalid
35+
36+
XCTAssertThrowsError(
37+
try CMTimeRange(start: s10, end: s9).timecodeRange(at: ._30)
38+
)
39+
}
40+
}
41+
42+
#endif

0 commit comments

Comments
 (0)