407bca37d8
* Fix Linux segfault in UsageFormatter localization (#2092) Bundle(for:) walks CFBundleGetAllBundles to locate the bundle that defines BundleToken, which needs Objective-C runtime introspection swift-corelibs-foundation can't provide on Linux — it crashes in _CFIsSwift there. CodexBarCore has no .lproj resources of its own (real localized strings are injected by the macOS app via setLocalizationProvider), so the Bundle(for:)/NSLocalizedString lookup was never useful on Linux to begin with. Skip it behind #if canImport(ObjectiveC) and fall straight through to the existing hardcoded English fallback table. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix: avoid Linux localization bundle crash --------- Co-authored-by: KaoOo Mac <thanthipmontein@192.168.1.184> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com> Co-authored-by: Peter Steinberger <steipete@gmail.com>
16 lines
578 B
Swift
16 lines
578 B
Swift
import CodexBarCore
|
|
import Testing
|
|
|
|
@Suite(.serialized)
|
|
struct UsageFormatterLinuxTests {
|
|
@Test
|
|
func `rate-window formatting uses the standalone English fallback`() {
|
|
UsageFormatter.clearLocalizationProvider()
|
|
UsageFormatter.clearLocaleProvider()
|
|
|
|
#expect(UsageFormatter.usageLine(remaining: 25, used: 75, showUsed: false) == "25% left")
|
|
#expect(UsageFormatter.usageLine(remaining: 25, used: 75, showUsed: true) == "75% used")
|
|
#expect(UsageFormatter.usageLine(remaining: 0.75, used: 99.25, showUsed: false) == "<1% left")
|
|
}
|
|
}
|