Defined the Randomable protocol in the library target.
This commit is contained in:
parent
17426f264a
commit
c5fc608c23
7
Library/Sources/Internal/Protocols/Randomable.swift
Normal file
7
Library/Sources/Internal/Protocols/Randomable.swift
Normal file
@ -0,0 +1,7 @@
|
||||
protocol Randomable: CaseIterable {
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
static func random() -> Self
|
||||
|
||||
}
|
32
Test/Sources/Cases/Internal/Protocols/RandomableTests.swift
Normal file
32
Test/Sources/Cases/Internal/Protocols/RandomableTests.swift
Normal file
@ -0,0 +1,32 @@
|
||||
import Testing
|
||||
|
||||
@testable import ColibriLibrary
|
||||
|
||||
struct RandomableTest {
|
||||
|
||||
@Test func random() {
|
||||
// GIVEN
|
||||
let allCases = TestRandomable.allCases
|
||||
|
||||
// WHEN
|
||||
let random = TestRandomable.random()
|
||||
|
||||
// THEN
|
||||
#expect(allCases.contains(random))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Enumerations
|
||||
|
||||
enum TestRandomable: Randomable {
|
||||
case someCase
|
||||
case someOtherCase
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
static func random() -> TestRandomable {
|
||||
.allCases.randomElement() ?? .someCase
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user