@@ -181,6 +181,48 @@ class Timecode_Rational_Tests: XCTestCase {
181
181
TCC ( h: 1 )
182
182
)
183
183
}
184
+
185
+ func testTimecode_RationalValue_Subframes( ) throws {
186
+ let tc = try TCC ( h: 00 , m: 00 , s: 01 , f: 11 , sf: 56 )
187
+ . toTimecode ( at: . _25, base: . _80SubFrames)
188
+ XCTAssertEqual ( tc. rationalValue, Fraction ( 367 , 250 ) )
189
+ }
190
+
191
+ func testTimecode_RationalSubframes( ) throws {
192
+ // 00:00:01:11.56 @ 25i fps, 80sf base
193
+ // this fraction is actually a little past 56 subframes
194
+ // because it was from FCPXML where it was not on an exact subframe
195
+ // FYI: when we convert it back to a fraction from timecode,
196
+ // the fraction ends up 367/250
197
+ let frac = Fraction ( 11011 , 7500 )
198
+ let tc = try frac. toTimecode ( at: . _25, base: . _80SubFrames)
199
+ XCTAssertEqual ( tc. components, TCC ( h: 00 , m: 00 , s: 01 , f: 11 , sf: 56 ) )
200
+ XCTAssertEqual ( tc. rationalValue, Fraction ( 367 , 250 ) )
201
+ }
202
+
203
+ func testTimecode_FrameCountOfRational( ) throws {
204
+ // 00:00:01:11.56 @ 25i fps, 80sf base
205
+ // this fraction is actually a little past 56 subframes
206
+ // because it was from FCPXML where it was not on an exact subframe
207
+ // FYI: when we convert it back to a fraction from timecode,
208
+ // the fraction ends up 367/250
209
+ let frac = Fraction ( 11011 , 7500 )
210
+ let tc = try frac. toTimecode ( at: . _25, base: . _80SubFrames)
211
+ let int = tc. frameCount ( of: frac)
212
+ XCTAssertEqual ( int, 36 )
213
+ }
214
+
215
+ func testTimecode_FloatingFrameCountOfRational( ) throws {
216
+ // 00:00:01:11.56 @ 25i fps, 80sf base
217
+ // this fraction is actually a little past 56 subframes
218
+ // because it was from FCPXML where it was not on an exact subframe
219
+ // FYI: when we convert it back to a fraction from timecode,
220
+ // the fraction ends up 367/250
221
+ let frac = Fraction ( 11011 , 7500 )
222
+ let tc = try frac. toTimecode ( at: . _25, base: . _80SubFrames)
223
+ let float = tc. floatingFrameCount ( of: frac)
224
+ XCTAssertEqual ( float, 36.70333333333333 )
225
+ }
184
226
}
185
227
186
228
#endif
0 commit comments