-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathComments+Currency.swift
45 lines (37 loc) · 1.7 KB
/
Comments+Currency.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//=----------------------------------------------------------------------------=
// This source file is part of the DiffableTextViews open source project.
//
// Copyright (c) 2022 Oscar Byström Ericsson
// Licensed under Apache License, Version 2.0
//
// See http://www.apache.org/licenses/LICENSE-2.0 for license information.
//=----------------------------------------------------------------------------=
#if DEBUG
import XCTest
//*============================================================================*
// MARK: * Comments x Tests x Currency
//*============================================================================*
final class CommentsOnCurrency: XCTestCase {
//=------------------------------------------------------------------------=
// MARK: Tests
//=------------------------------------------------------------------------=
func testCurrencySymbolsAreSometimesReal() {
let number = -1234567.89
let currencyCode = "PAB"
let locale = Locale(identifier: "rhg-Rohg_MM")
let formatted = number.formatted(.currency(code: currencyCode).locale(locale))
XCTAssertEqual(formatted, "-B/. 1,234,567.89") // currency contains a fraction separator
}
func testCurrencySymbolsDoNotContainNumbers() {
//=--------------------------------------=
// Locales, Currencies
//=--------------------------------------=
for locale in locales {
for code in currencyCodes {
let zero = 0.formatted(.currency(code: code).locale(locale).precision(.fractionLength(0)))
XCTAssert(zero.count(where: \.isNumber) == 1, "\(zero), \(locale), \(code)")
}
}
}
}
#endif