mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2026-03-18 20:02:25 +00:00
50aa8c51cc
* Fixed glob segmentation fault * Renamed AtomicDictionary to ThreadSafeDictionary * Refactored ThreadSafeDictionary * ThreadSafeDictionary replaced with ThreadSafeContainer * Removed reader/writer * ThreadSafeContainer replaced with Atomic
40 lines
932 B
Swift
40 lines
932 B
Swift
//
|
|
// AtomicTests.swift
|
|
//
|
|
//
|
|
// Created by Vladislav Lisianskii on 27.03.2022.
|
|
//
|
|
|
|
import XCTest
|
|
@testable import XcodeGenCore
|
|
|
|
final class AtomicTests: XCTestCase {
|
|
|
|
@Atomic private var atomicDictionary = [String: Int]()
|
|
|
|
func testSimultaneousWriteOrder() {
|
|
let group = DispatchGroup()
|
|
|
|
for index in (0..<100) {
|
|
group.enter()
|
|
DispatchQueue.global().async {
|
|
self.$atomicDictionary.with { atomicDictionary in
|
|
atomicDictionary["\(index)"] = index
|
|
}
|
|
group.leave()
|
|
}
|
|
}
|
|
|
|
group.notify(queue: .main, execute: {
|
|
var expectedValue = [String: Int]()
|
|
for index in (0..<100) {
|
|
expectedValue["\(index)"] = index
|
|
}
|
|
XCTAssertEqual(
|
|
self.atomicDictionary,
|
|
expectedValue
|
|
)
|
|
})
|
|
}
|
|
}
|