Skip to content

Commit 8ba8704

Browse files
vAhyTheclaude
andcommitted
Add CZK to the preferred currency picker
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent a90dfed commit 8ba8704

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

Sources/CodexBar/PreferencesGeneralPane.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ enum PreferredCurrencyOption: String, CaseIterable, Identifiable {
8080
case usd = "USD"
8181
case gbp = "GBP"
8282
case eur = "EUR"
83+
case czk = "CZK"
8384
case cny = "CNY"
8485
case jpy = "JPY"
8586
case krw = "KRW"
@@ -100,6 +101,7 @@ enum PreferredCurrencyOption: String, CaseIterable, Identifiable {
100101
case .usd: "USD ($)"
101102
case .gbp: "GBP (£)"
102103
case .eur: "EUR (€)"
104+
case .czk: "CZK (Kč)"
103105
case .cny: "CNY (¥)"
104106
case .jpy: "JPY (¥)"
105107
case .krw: "KRW (₩)"

Sources/CodexBarCore/CurrencyExchange.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public final class CurrencyExchange: @unchecked Sendable {
1515

1616
/// All currency codes supported by the converter.
1717
public static let supportedCurrencies: [String] = [
18-
"USD", "GBP", "EUR", "CNY", "JPY", "KRW", "CAD", "AUD", "HKD", "TWD", "SGD", "INR",
18+
"USD", "GBP", "EUR", "CZK", "CNY", "JPY", "KRW", "CAD", "AUD", "HKD", "TWD", "SGD", "INR",
1919
]
2020

2121
private let lock = NSLock()
@@ -25,6 +25,7 @@ public final class CurrencyExchange: @unchecked Sendable {
2525
"USD": 1.0,
2626
"GBP": 0.79,
2727
"EUR": 0.92,
28+
"CZK": 21.0,
2829
"CNY": 7.27,
2930
"JPY": 154.0,
3031
"KRW": 1428.90,

Tests/CodexBarTests/UsageFormatterTests.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,12 @@ struct UsageFormatterTests {
517517
#expect(explicitKRW.contains(""))
518518
#expect(!explicitKRW.contains("."))
519519

520+
let czkRate = exchange.rate(for: "CZK") ?? 21.0
521+
#expect(abs((exchange.convert(usdAmount: 10.0, to: "CZK") ?? 0) - 10.0 * czkRate) < epsilon)
522+
let explicitCZK = UsageFormatter.convertedCostString(10.0, preferredCurrency: "CZK", providerCurrency: "USD")
523+
#expect(explicitCZK.contains("CZK"))
524+
#expect(explicitCZK.contains("."))
525+
520526
#expect(exchange.convert(amount: 10.0, from: "CHF", to: "USD") == nil)
521527
let unavailable = UsageFormatter.convertedCostString(
522528
10.0,
@@ -535,6 +541,7 @@ struct UsageFormatterTests {
535541
#expect(CurrencyExchange.requiresLiveRates(preferredCurrencyCode: "GBP"))
536542
#expect(CurrencyExchange.requiresLiveRates(preferredCurrencyCode: " eur "))
537543
#expect(CurrencyExchange.requiresLiveRates(preferredCurrencyCode: "KRW"))
544+
#expect(CurrencyExchange.requiresLiveRates(preferredCurrencyCode: "CZK"))
538545
}
539546

540547
@Test

0 commit comments

Comments
 (0)