Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions Sources/XcodeGraph/Extensions/SettingsDictionary+Extras.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,9 @@ extension SettingsDictionary {
}
switch oldValue {
case let .array(values):
return .array(
Array(
Set(values + newValues)
)
)
return .array(values + newValues)
case let .string(value):
return .array(
Array(
Set(
value.split(separator: " ").map(String.init) + newValues
)
)
)
return .array(value.split(separator: " ").map(String.init) + newValues)
}
})
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,46 +1,9 @@
import Foundation
import Testing
import XCTest

@testable import XcodeGraph

struct SettingsDictionaryExtrasTest {
@Test
func test_combine_doesNotIncludeDuplicates() {
// Given
let settings: [String: SettingValue] = [
"A": .array(["first value", "second value"]),
]

// When
let got = settings.combine(
with: [
"A": .array(
[
"first value", "third value",
]
),
]
)
.mapValues { value -> SettingValue in
switch value {
case let .array(values): return .array(values.sorted())
default: return value
}
}

// Then
#expect(
got == [
"A": .array(
[
"first value", "second value", "third value",
]
),
]
)
}

@Test
final class SettingsDictionaryExtrasTest: XCTestCase {
func testOverlay_addsPlatformSpecifierWhenSettingsDiffer() {
// Given
var settings: [String: SettingValue] = [
Expand All @@ -56,13 +19,11 @@ struct SettingsDictionaryExtrasTest {
], for: .macOS)

// Then
#expect(
settings == [
"A[sdk=macosx*]": "overlayed value",
"A": "a value",
"B": "b value",
"C[sdk=macosx*]": "c value",
]
)
XCTAssertEqual(settings, [
"A[sdk=macosx*]": "overlayed value",
"A": "a value",
"B": "b value",
"C[sdk=macosx*]": "c value",
])
}
}