mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This is needed if we compile StdlibUnittest with -sil-serialize-all So far I added the imports only in files which needed them. But this may change, depending on the optimizer (inlining). Adding them in all files doesn't harm and avoids confusion if someone makes an unrelated change which would result in such a linker error.
95 lines
3.0 KiB
Swift
95 lines
3.0 KiB
Swift
// RUN: %target-run-simple-swift
|
|
// REQUIRES: executable_test
|
|
|
|
// REQUIRES: objc_interop
|
|
// UNSUPPORTED: OS=watchos
|
|
|
|
import StdlibUnittest
|
|
|
|
// Also import modules which are used by StdlibUnittest internally. This
|
|
// workaround is needed to link all required libraries in case we compile
|
|
// StdlibUnittest with -sil-serialize-all.
|
|
import SwiftPrivate
|
|
#if _runtime(_ObjC)
|
|
import ObjectiveC
|
|
#endif
|
|
|
|
import CoreMedia
|
|
|
|
var CoreMediaTests = TestSuite("CoreMedia")
|
|
|
|
// This is a basic smoke test to check that the overlay works. It should be
|
|
// replaced with comprehensive tests.
|
|
CoreMediaTests.test("OverlaySmokeTest") {
|
|
expectTrue(CMTimeMake(1, 10).isValid)
|
|
expectTrue(CMTimeRangeMake(CMTimeMake(1, 10), CMTimeMake(2, 20)).isValid)
|
|
}
|
|
|
|
CoreMediaTests.test("CMTime(value:timescale:)") {
|
|
let time = CMTime(value: 7, timescale: 1)
|
|
expectTrue(time.isValid)
|
|
expectEqual(7, time.value)
|
|
expectEqual(1, time.timescale)
|
|
}
|
|
|
|
CoreMediaTests.test("CMTime(seconds:preferredTimescale:)") {
|
|
let time = CMTime(seconds: 7.0, preferredTimescale: 600)
|
|
expectTrue(time.isValid)
|
|
expectEqual(7.0, time.seconds)
|
|
}
|
|
|
|
CoreMediaTests.test("CMTime/Comparable") {
|
|
let instances: [(Int, CMTime)] = [
|
|
(-9999, CMTime(seconds: -Double.infinity, preferredTimescale: 600)),
|
|
(10, CMTime(seconds: 10.0, preferredTimescale: 600)),
|
|
(10, CMTime(seconds: 10.0, preferredTimescale: 600)),
|
|
(20, CMTime(seconds: 20.0, preferredTimescale: 600)),
|
|
(30, CMTime(seconds: 30.0, preferredTimescale: 600)),
|
|
(9999, CMTime(seconds: Double.infinity, preferredTimescale: 600)),
|
|
]
|
|
func comparisonOracle(i: Int, j: Int) -> ExpectedComparisonResult {
|
|
return instances[i].0 <=> instances[j].0
|
|
}
|
|
checkComparable(instances.map { $0.1 }, oracle: comparisonOracle)
|
|
}
|
|
|
|
CoreMediaTests.test("CMTimeRange(start:duration:)") {
|
|
let start = CMTime(seconds: 10.0, preferredTimescale: 600)
|
|
let duration = CMTime(seconds: 5.0, preferredTimescale: 600)
|
|
let range = CMTimeRange(start: start, duration: duration)
|
|
expectEqual(start, range.start)
|
|
expectEqual(duration, range.duration)
|
|
}
|
|
|
|
CoreMediaTests.test("CMTimeRange(start:end:)") {
|
|
let start = CMTime(seconds: 10.0, preferredTimescale: 600)
|
|
let end = CMTime(seconds: 20.0, preferredTimescale: 600)
|
|
let range = CMTimeRange(start: start, end: end)
|
|
expectEqual(start, range.start)
|
|
expectEqual(end, range.end)
|
|
}
|
|
|
|
CoreMediaTests.test("CMTimeRange/Equatable") {
|
|
let time10 = CMTime(seconds: 10.0, preferredTimescale: 600)
|
|
let time20 = CMTime(seconds: 20.0, preferredTimescale: 600)
|
|
let timeInf = CMTime(seconds: Double.infinity, preferredTimescale: 600)
|
|
|
|
let instances: [(Int, CMTimeRange)] = [
|
|
(10, CMTimeRangeMake(time10, time10)),
|
|
(10, CMTimeRangeMake(time10, time10)),
|
|
|
|
(20, CMTimeRangeMake(time10, time20)),
|
|
(20, CMTimeRangeMake(time10, time20)),
|
|
|
|
(9999, CMTimeRangeMake(timeInf, time20)),
|
|
(9999, CMTimeRangeMake(timeInf, time20)),
|
|
]
|
|
func comparisonOracle(i: Int, j: Int) -> Bool {
|
|
return instances[i].0 == instances[j].0
|
|
}
|
|
checkEquatable(instances.map { $0.1 }, oracle: comparisonOracle)
|
|
}
|
|
|
|
runAllTests()
|
|
|