Skip to content

Commit c5b8de8

Browse files
committed
Updated unit tests
1 parent 342092f commit c5b8de8

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

Tests/TimecodeKit-Unit-Tests/Unit Tests/Timecode/Timecode Conversion Tests.swift

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ class Timecode_Conversion_Tests: XCTestCase {
1313
override func setUp() { }
1414
override func tearDown() { }
1515

16-
func testConverted() throws {
16+
func testConverted_NewFrameRate() throws {
1717
// baseline check:
1818
// ensure conversion produces identical output if frame rates are equal
1919

2020
try TimecodeFrameRate.allCases.forEach {
21-
let tc = try Timecode(.components(h: 1), at: $0)
21+
let tc = try Timecode(.components(h: 1), at: $0, base: .max100SubFrames)
2222

2323
let convertedTC = try tc.converted(to: $0)
2424

@@ -35,10 +35,41 @@ class Timecode_Conversion_Tests: XCTestCase {
3535
.converted(to: .fps30)
3636

3737
XCTAssertEqual(convertedTC.frameRate, .fps30)
38+
XCTAssertEqual(convertedTC.subFramesBase, .max100SubFrames)
3839
XCTAssertEqual(convertedTC.components, Timecode.Components(h: 1, m: 00, s: 03, f: 18, sf: 00))
3940
}
4041

41-
func testConverted_PreservingValues() throws {
42+
func testConverted_NewFrameRate_NewSubFramesBaseA() throws {
43+
// spot-check an example conversion
44+
45+
let convertedTC = try Timecode(
46+
.components(sf: 50),
47+
at: .fps30,
48+
base: .max100SubFrames
49+
)
50+
.converted(to: .fps60, base: .max80SubFrames)
51+
52+
XCTAssertEqual(convertedTC.frameRate, .fps60)
53+
XCTAssertEqual(convertedTC.subFramesBase, .max80SubFrames)
54+
XCTAssertEqual(convertedTC.components, Timecode.Components(f: 1))
55+
}
56+
57+
func testConverted_NewFrameRate_NewSubFramesBaseB() throws {
58+
// spot-check an example conversion
59+
60+
let convertedTC = try Timecode(
61+
.components(h: 1, sf: 40),
62+
at: .fps23_976,
63+
base: .max80SubFrames
64+
)
65+
.converted(to: .fps30, base: .max100SubFrames)
66+
67+
XCTAssertEqual(convertedTC.frameRate, .fps30)
68+
XCTAssertEqual(convertedTC.subFramesBase, .max100SubFrames)
69+
XCTAssertEqual(convertedTC.components, Timecode.Components(h: 1, m: 00, s: 03, f: 18, sf: 62))
70+
}
71+
72+
func testConverted_NewFrameRate_PreservingValues() throws {
4273
// baseline check:
4374
// ensure conversion produces identical output if frame rates are equal
4475

0 commit comments

Comments
 (0)