Skip to content

Commit

Permalink
Add a helper generating parameter dictionaries from enums
Browse files Browse the repository at this point in the history
  • Loading branch information
aleh committed Nov 30, 2023
1 parent f184db3 commit 0cfb521
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion MMMTestCase.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Pod::Spec.new do |s|

s.name = "MMMTestCase"
s.version = "1.8.0"
s.version = "1.9.0"
s.summary = "Our helpers for FBTestCase and XCTestCase"
s.description = s.summary
s.homepage = "https://github.com/mediamonks/#{s.name}"
Expand Down
10 changes: 10 additions & 0 deletions Sources/MMMTestCase/MMMTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//

import Foundation
import MMMCommonCore
import UIKit

#if SWIFT_PACKAGE
Expand Down Expand Up @@ -87,4 +88,13 @@ extension MMMTestCase {
)

}

/// Helps generating parameter dictionaries suitable for `varyParameters` from enums supporting `CaseIterable`.
public func allTestCases<T: CaseIterable>(_ type: T.Type) -> [String: T] {
.init(uniqueKeysWithValues:
T.allCases
.map { (String(MMMTypeName($0).split(separator: ".").last!), $0) }
.sorted { a, b in a.0 < b.0 }
)
}
}

0 comments on commit 0cfb521

Please sign in to comment.