Repository Public BSD-3-Clause
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project : ORIX Maps9// File : Packages/ORIXDesignSystem/Tests/ORIXDesignSystemTests/FormatterTests.swift10// Module : ORIXDesignSystemTests11// Repository : https://git.spboucher.ai/orix-maps12// Created : 2026-11-2513// Last Modified : 2026-11-2514//15// =============================================================================16// AUTHOR & PROFESSIONAL AFFILIATION17// =============================================================================18//19// Author : Simon-Pierre Boucher20// Position : Professor of Finance21// Institution : Université du Québec en Outaouais (UQO)22// Department : Département des sciences administratives23// Organization : SP Boucher24//25// Website : https://spboucher.ai26// Git : https://git.spboucher.ai27//28// =============================================================================29// OFFICIAL CONTACT DIRECTORY30// =============================================================================31//32// General : info@spboucher.ai33// Professional : contact@spboucher.ai34// Direct : simon@spboucher.ai35// Research : research@spboucher.ai36// Development : dev@spboucher.ai37// Support : support@spboucher.ai38// Security/Admin : admin@spboucher.ai39// Notifications : notifications@spboucher.ai40//41// Preferred Contact: support@spboucher.ai42//43// =============================================================================44// COPYRIGHT & INTELLECTUAL PROPERTY45// =============================================================================46//47// Copyright (c) 202648// Simon-Pierre Boucher49//50// All rights reserved where applicable.51//52// This file is governed by the applicable project license,53// copyright notices, institutional agreements and relevant law.54//55// Unless expressly authorized by the applicable license or56// rights holder, copying, redistribution, sublicensing,57// publication and commercial exploitation are not permitted.58//59// Existing third-party rights and notices remain unaffected.60//61// =============================================================================62// CONFIDENTIALITY & SECURITY63// =============================================================================64//65// Classification : Public66// Distribution : Public repository; use is governed by the project license67// Security Contact : admin@spboucher.ai68//69// Access to this source does not independently grant permission70// to redistribute or disclose confidential materials.71//72// Do not embed credentials, private keys, access tokens,73// certificates or confidential personal information.74//75// =============================================================================76// LICENSE & MAINTENANCE77// =============================================================================78//79// License : Proprietary, all rights reserved (see license file)80// License File : LICENSE81// Maintainer : Simon-Pierre Boucher82// Technical Contact: dev@spboucher.ai83//84// =============================================================================85// END OF SP BOUCHER SOURCE HEADER86// =============================================================================8788import Foundation89import Testing90@testable import ORIXDesignSystem9192@Suite struct MeasureFormatterTests {93 private let metric = MeasureFormatter(system: .metric, locale: Locale(identifier: "en_CA"))94 private let imperial = MeasureFormatter(system: .imperial, locale: Locale(identifier: "en_US"))95 private let french = MeasureFormatter(system: .metric, locale: Locale(identifier: "fr_CA"))9697 @Test func distances() {98 #expect(metric.distance(0) == "0 m")99 #expect(metric.distance(83) == "85 m")100 #expect(metric.distance(456) == "460 m")101 #expect(metric.distance(1_250) == "1.3 km" || metric.distance(1_250) == "1.2 km")102 #expect(metric.distance(12_600) == "13 km")103 #expect(french.distance(1_540) == "1,5 km")104 #expect(imperial.distance(100) == "330 ft")105 #expect(imperial.distance(1_000) == "0.6 mi")106 #expect(imperial.distance(32_187) == "20 mi")107 #expect(metric.distance(-1) == "—" && metric.distance(.nan) == "—")108 }109110 @Test func durationsSpeedsAreasAltitudes() {111 #expect(metric.duration(45) == "45 s")112 #expect(metric.duration(12 * 60 + 20) == "12 min")113 #expect(metric.duration(2 * 3600 + 5 * 60) == "2 h 05")114 #expect(metric.duration(.infinity) == "—")115 #expect(metric.speed(metersPerSecond: 27.78) == "100 km/h")116 #expect(imperial.speed(metersPerSecond: 27.78) == "62 mph")117 #expect(metric.area(850) == "850 m²")118 #expect(metric.area(12_000) == "1.2 ha")119 #expect(metric.area(3_400_000) == "3.4 km²")120 #expect(imperial.area(4_046.86) == "1.0 ac")121 #expect(metric.altitude(233.4) == "233 m" && imperial.altitude(100) == "328 ft")122 }123}124