Skip to content
This repository has been archived by the owner on Jul 11, 2024. It is now read-only.

Commit

Permalink
Add test to ensure that all valid pattern sequences exist within each…
Browse files Browse the repository at this point in the history
… format object provided (#18)
  • Loading branch information
liamnichols authored Apr 4, 2019
1 parent 4e26c4b commit 785a763
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions Tests/FormatProviderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,40 @@ class FormatProviderTests: XCTestCase {
XCTAssertNil(format)
}
}

class FormatProviderPatternTests: XCTestCase {

func testAllPatternsInBundle() throws {

let bundle = Bundle(for: ListItemFormatter.self)

let localeInformation = try LocaleInformation(bundle: bundle)
let provider = FormatProvider(bundle: bundle)

XCTAssertFalse(localeInformation.localeIdentifiers.isEmpty)

let combinations: [(ListItemFormatter.Mode, ListItemFormatter.Style)] = [
(.standard, .default),
(.standard, .short),
(.standard, .narrow),
(.or, .default),
(.or, .short),
(.or, .narrow),
(.unit, .default),
(.unit, .short),
(.unit, .narrow),
]

for identifier in localeInformation.localeIdentifiers {
for (mode, style) in combinations {

let locale = Locale(identifier: identifier)
let format = provider.format(for: locale)
let patterns = format?.getPatterns(for: style, mode: mode)

XCTAssertNotNil(format)
XCTAssertNotNil(patterns)
}
}
}
}

0 comments on commit 785a763

Please sign in to comment.