crossmate

A collaborative crossword app for iOS
Log | Files | Refs | LICENSE

PlayerColorTests.swift (1423B)


      1 import Foundation
      2 import Testing
      3 
      4 @testable import Crossmate
      5 
      6 @Suite("PlayerColor")
      7 struct PlayerColorTests {
      8 
      9     @Test("Single blue-anchor companion can rotate through every curated colour")
     10     func singleBlueAnchorCompanionUsesEveryCuratedColor() {
     11         let examples: [(String, String)] = [
     12             ("00000000-0000-0000-0000-000000000035", "red"),
     13             ("00000000-0000-0000-0000-000000000004", "yellow"),
     14             ("00000000-0000-0000-0000-000000000000", "green"),
     15             ("00000000-0000-0000-0000-000000000010", "pink"),
     16             ("00000000-0000-0000-0000-000000000001", "orange"),
     17             ("00000000-0000-0000-0000-000000000009", "purple"),
     18         ]
     19 
     20         let assigned = examples.map { uuidString, _ in
     21             PlayerColor.assignedCompanions(
     22                 forSortedAuthorIDs: ["_B"],
     23                 inGame: UUID(uuidString: uuidString)!,
     24                 anchor: .blue
     25             ).first?.id
     26         }
     27 
     28         #expect(assigned == examples.map(\.1))
     29     }
     30 
     31     @Test("Companion option rotation wraps within the curated set")
     32     func companionOptionRotationWrapsWithinCuratedSet() {
     33         let colors = PlayerColor.assignedCompanions(
     34             forSortedAuthorIDs: ["_B", "_C", "_D"],
     35             inGame: UUID(uuidString: "00000000-0000-0000-0000-000000000004")!,
     36             anchor: .blue
     37         ).map(\.id)
     38 
     39         #expect(colors == ["yellow", "green", "red"])
     40     }
     41 }