Skip to content

Commit

Permalink
Merge pull request #1748 from spevans/pr_icu_test_fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
swift-ci committed Nov 29, 2018
2 parents 50c0ac9 + 0eeb5a0 commit 248fc2e
Showing 1 changed file with 30 additions and 41 deletions.
71 changes: 30 additions & 41 deletions TestFoundation/TestNumberFormatter.swift
Expand Up @@ -30,9 +30,9 @@ class TestNumberFormatter: XCTestCase {
("test_scientificMinimumIntegerDigits", test_scientificMinimumIntegerDigits),
("test_spellOutMinimumIntegerDigits", test_spellOutMinimumIntegerDigits),
("test_ordinalMinimumIntegerDigits", test_ordinalMinimumIntegerDigits),
// XFAIL: breaks on Ubuntu 14.04 probably ICU - ("test_currencyPluralMinimumIntegerDigits", test_currencyPluralMinimumIntegerDigits),
// XFAIL: breaks on Ubuntu 14.04 probably ICU - ("test_currencyISOCodeMinimumIntegerDigits", test_currencyISOCodeMinimumIntegerDigits),
// XFAIL: breaks on Ubuntu 14.04 probably ICU - ("test_currencyAccountingMinimumIntegerDigits", test_currencyAccountingMinimumIntegerDigits),
("test_currencyPluralMinimumIntegerDigits", test_currencyPluralMinimumIntegerDigits),
("test_currencyISOCodeMinimumIntegerDigits", test_currencyISOCodeMinimumIntegerDigits),
("test_currencyAccountingMinimumIntegerDigits", test_currencyAccountingMinimumIntegerDigits),
("test_maximumIntegerDigits", test_maximumIntegerDigits),
("test_minimumFractionDigits", test_minimumFractionDigits),
("test_maximumFractionDigits", test_maximumFractionDigits),
Expand All @@ -59,15 +59,12 @@ class TestNumberFormatter: XCTestCase {
}

func test_currencyCode() {
// Disabled due to [SR-250]
/*
let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .CurrencyStyle
numberFormatter.numberStyle = .currency
numberFormatter.currencyCode = "T"
numberFormatter.currencyDecimalSeparator = "_"
let formattedString = numberFormatter.stringFromNumber(42)
XCTAssertEqual(formattedString, "T 42_00")
*/
let formattedString = numberFormatter.string(from: 42)
XCTAssertEqual(formattedString, "T42_00")
}

func test_decimalSeparator() {
Expand All @@ -83,15 +80,12 @@ class TestNumberFormatter: XCTestCase {
}

func test_currencyDecimalSeparator() {
// Disabled due to [SR-250]
/*
let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .CurrencyStyle
numberFormatter.numberStyle = .currency
numberFormatter.currencyDecimalSeparator = "-"
numberFormatter.currencyCode = "T"
let formattedString = numberFormatter.stringFromNumber(42.42)
XCTAssertEqual(formattedString, "T 42-42")
*/
let formattedString = numberFormatter.string(from: 42.42)
XCTAssertEqual(formattedString, "T42-42")
}

func test_alwaysShowDecimalSeparator() {
Expand Down Expand Up @@ -191,15 +185,12 @@ class TestNumberFormatter: XCTestCase {
}

func test_currencySymbol() {
// Disabled due to [SR-250]
/*
let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .CurrencyStyle
numberFormatter.numberStyle = .currency
numberFormatter.currencySymbol = "🍯"
numberFormatter.currencyDecimalSeparator = "_"
let formattedString = numberFormatter.stringFromNumber(42)
XCTAssertEqual(formattedString, "🍯 42_00")
*/
let formattedString = numberFormatter.string(from: 42)
XCTAssertEqual(formattedString, "🍯42_00")
}

func test_exponentSymbol() {
Expand Down Expand Up @@ -527,28 +518,26 @@ class TestNumberFormatter: XCTestCase {
}

func test_internationalCurrencySymbol() {
// Disabled due to [SR-250]
/*
// What does internationalCurrencySymbol actually do?
#if false
let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .CurrencyPluralStyle
numberFormatter.numberStyle = .currencyPlural
numberFormatter.internationalCurrencySymbol = "💵"
numberFormatter.currencyDecimalSeparator = "_"
let formattedString = numberFormatter.stringFromNumber(42)
XCTAssertEqual(formattedString, "💵 42_00")
*/
let formattedString = numberFormatter.string(from: 42)
XCTAssertEqual(formattedString, "💵42_00")
#endif
}

func test_currencyGroupingSeparator() {
// Disabled due to [SR-250]
/*
let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .CurrencyStyle
numberFormatter.numberStyle = .currency
numberFormatter.currencyGroupingSeparator = "_"
numberFormatter.currencyCode = "T"
numberFormatter.currencyDecimalSeparator = "/"
let formattedString = numberFormatter.stringFromNumber(42_000)
XCTAssertEqual(formattedString, "T 42_000/00")
*/
let formattedString = numberFormatter.string(from: 42_000)
XCTAssertEqual(formattedString, "T42_000/00")

}

func test_lenient() {
Expand All @@ -569,13 +558,14 @@ class TestNumberFormatter: XCTestCase {
XCTAssertEqual(number, 2.22)

// TODO: Add some tests with currency after [SR-250] resolved
// numberFormatter.numberStyle = .currency
// let nilNumberBeforeLenient = numberFormatter.number(from: "42")
//
// XCTAssertNil(nilNumberBeforeLenient)
// numberFormatter.isLenient = true
// let numberAfterLenient = numberFormatter.number(from: "42.42")
// XCTAssertEqual(numberAfterLenient, 42.42)
numberFormatter.numberStyle = .currency
numberFormatter.isLenient = false
let nilNumberBeforeLenient = numberFormatter.number(from: "42")

XCTAssertNil(nilNumberBeforeLenient)
numberFormatter.isLenient = true
let numberAfterLenient = numberFormatter.number(from: "42.42")
XCTAssertEqual(numberAfterLenient, 42.42)
}

func test_minimumSignificantDigits() {
Expand Down Expand Up @@ -683,4 +673,3 @@ class TestNumberFormatter: XCTestCase {
XCTAssertEqual(numberFormatter.paddingCharacter, " ")
}
}

0 comments on commit 248fc2e

Please sign in to comment.