Skip to content

Commit

Permalink
Rewrite of TextInt+Letters.swift tests (#110).
Browse files Browse the repository at this point in the history
  • Loading branch information
oscbyspro committed Oct 29, 2024
1 parent 47ef173 commit 650bfd7
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions Tests/UltimathnumTests/TextInt+Letters.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,41 @@
//=----------------------------------------------------------------------------=

import CoreKit
import TestKit
import TestKit2

//*============================================================================*
// MARK: * Text Int x Letters
//*============================================================================*

final class TextIntTestsOnLetters: XCTestCase {
@Suite(Tag.List.tags(.exhaustive), ParallelizationTrait.serialized)
struct TextIntTestsOnLetters {

//=------------------------------------------------------------------------=
// MARK: Tests
//=------------------------------------------------------------------------=

func testInitBool() {
Test().same(TextInt.Letters(uppercase: false), TextInt.Letters.lowercase)
Test().same(TextInt.Letters(uppercase: true ), TextInt.Letters.uppercase)

@Test("TextInt.Letters: start", arguments: [
(instance: TextInt.Letters.lowercase, start: 97 as U8),
(instance: TextInt.Letters.uppercase, start: 65 as U8),
] as [(TextInt.Letters, U8)])
func start(instance: TextInt.Letters, start: U8) throws {
#expect(instance.start == start)

let numerals = try TextInt.Numerals(radix: 36, letters: instance)
#expect(try numerals.decode(start) == 10)
#expect(try numerals.encode(10) == start)
}

func testGetStart() {
Test().same(TextInt.Letters.lowercase.start, U8(UInt8(ascii: "a")))
Test().same(TextInt.Letters.uppercase.start, U8(UInt8(ascii: "A")))
@Test("TextInt.Letters: uppercase", arguments: [
(instance: TextInt.Letters.lowercase, uppercase: false),
(instance: TextInt.Letters.uppercase, uppercase: true ),
] as [(TextInt.Letters, Bool)])
func uppercase(instance: TextInt.Letters, uppercase: Bool) {
#expect((instance == TextInt.Letters (uppercase: uppercase)))
#expect((instance == TextInt.Letters .uppercase) == uppercase)
}
}

0 comments on commit 650bfd7

Please sign in to comment.