FormatTests.swift (996B)
1 // SPDX-License-Identifier: GPL-2.0-only 2 import Foundation 3 import Testing 4 import RemoraDeco 5 @testable import RemoraUI 6 7 @Suite("Format") 8 struct FormatTests { 9 @Test func clockAndDurations() { 10 #expect(Format.clock(754) == "12:34") 11 #expect(Format.clock(3723) == "1:02:03") 12 #expect(Format.minutes(2520) == "42 min") 13 #expect(Format.hours(3.08) == "3 h 05") 14 #expect(Format.hours(0.75) == "45 min") 15 } 16 17 @Test func noDecompressionLimit() { 18 #expect(Format.ndl(nil) == ">99") 19 #expect(Format.ndl(120) == ">99") 20 #expect(Format.ndl(17.8) == "17") 21 } 22 23 @Test func decimalsFollowTheInterfaceLanguage() { 24 #expect(Format.depth(12.34) == (Format.isFrench ? "12,3" : "12.3")) 25 } 26 27 @Test func everyWarningHasALabelAndALevel() { 28 for warning in DiveComputer.Warning.allCases { 29 #expect(!warning.label.isEmpty) 30 #expect(warning.color == (warning.isViolation ? .red : .orange)) 31 } 32 } 33 }