cb72197f8e
* initial work for supporting non-optimised mp4 * Update AppCoordinator.swift * some refactor and fixed seek for a restructured mp4 * nit * nit * nit * runs swiftlint * improvements * improvements * handles case where we the stream is not seekable for an mp4 file * better check for mp4, seekable and moov atom * nit * fix an issue with seek * some refactoring
38 lines
947 B
Swift
38 lines
947 B
Swift
//
|
|
// Created by Dimitrios Chatzieleftheriou on 22/05/2020.
|
|
// Copyright © 2020 Decimal. All rights reserved.
|
|
//
|
|
|
|
import XCTest
|
|
|
|
@testable import AudioStreaming
|
|
|
|
class AtomicTests: XCTestCase {
|
|
func testProtectedValuesAreAccessedSafely() {
|
|
measure {
|
|
let atomic = Atomic<Int>(0)
|
|
|
|
DispatchQueue.concurrentPerform(iterations: 100_000) { _ in
|
|
_ = atomic.value
|
|
atomic.write { $0 += 1 }
|
|
}
|
|
|
|
XCTAssertEqual(atomic.value, 100_000)
|
|
}
|
|
}
|
|
|
|
func testThatProtectedReadAndWriteAreSafe() {
|
|
measure {
|
|
let initialValue = "aValue"
|
|
let protected = Atomic<String>(initialValue)
|
|
|
|
DispatchQueue.concurrentPerform(iterations: 1000) { i in
|
|
_ = protected.value
|
|
protected.write { $0 = "\(i)" }
|
|
}
|
|
|
|
XCTAssertNotEqual(protected.value, initialValue)
|
|
}
|
|
}
|
|
}
|