File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed
Tests/TimecodeKit-Unit-Tests/Unit Tests/AVFoundation Extensions Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change
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
You can’t perform that action at this time.
0 commit comments