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

Add FormatProviderPatternTests #18

Merged
merged 1 commit into from
Apr 4, 2019
Merged
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
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)
}
}
}
}