Files
pokerfreak-shell/mac/Tests/Pruefung/FormateSpec.swift
T
mmintelandClaude Opus 5.5 83a31b3831 Mac-App: "Was spielen" mit Tischen je Format, "Formate im Vergleich"
A card per format with its table count under the plan tiles (unmeasured
formats are marked), the table tile shows the sum. Results show bb/100
per format with its 95 % span on a shared axis and the verdict, Practice
and Live separately.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 10:43:23 +01:00

91 lines
3.6 KiB
Swift

import CockpitKern
import Testing
@Suite("Formate im Spielplan: Tische je Format, wie betrieb/spielplan.py")
struct FormateSpec {
@Test("ein neuer Plan ist Cash mit seiner Tischzahl")
func neu() {
let p = Spielplan(modus: .uebung, tische: 3, budget: nil)
#expect(p.formate == [.cash: 3])
#expect(p.tische == 3)
}
@Test("je Format setzen; die Summe ist die Tischzahl")
func setzen() {
var p = Spielplan(modus: .echt, tische: 2, budget: 100)
p.setzen(.aof, 1)
p.setzen(.bombpot, 2)
#expect(p.formate == [.cash: 2, .aof: 1, .bombpot: 2])
#expect(p.tische == 5)
p.setzen(.cash, 0)
#expect(p.formate == [.aof: 1, .bombpot: 2])
#expect(p.anzahl(.cash) == 0)
}
@Test("die Summe bleibt unter hoechstens")
func grenze() {
var p = Spielplan(modus: .uebung, tische: 10, budget: nil)
p.setzen(.aof, 9)
#expect(p.anzahl(.aof) == Spielplan.hoechstens - 10)
#expect(p.tische == Spielplan.hoechstens)
p.setzen(.aof, -3)
#expect(p.anzahl(.aof) == 0)
}
@Test("an den Läufer: formate und eine Tischzahl von mindestens 1")
func daten() {
var p = Spielplan(modus: .uebung, tische: 1, budget: nil)
p.setzen(.aof, 2)
#expect(p.daten["formate"] as? [String: Int] == ["cash": 1, "aof": 2])
#expect(p.daten["tische"] as? Int == 3)
p.setzen(.cash, 0); p.setzen(.aof, 0)
#expect(p.daten["formate"] as? [String: Int] == [:])
#expect(p.daten["tische"] as? Int == 1)
#expect(Spielplan(modus: .uebung, tische: 2, budget: nil).daten["formate"] == nil) // nur Cash: Vorgabe
}
@Test("vom Server: formate und welche Formate gemessen sind")
func gelesen() {
let p = Hilfen.spielplan(#"""
{"modus":"echt","tische":3,"formate":{"cash":2,"aof":1,"erfunden":4},
"formate_liste":[{"format":"cash","name":"Cash","gemessen":true},{"format":"aof","name":"All-In or Fold","gemessen":false}]}
"""#)
#expect(p?.formate == [.cash: 2, .aof: 1])
#expect(p?.gemessen == [.cash])
}
@Test("ein alter Plan ohne formate ist Cash")
func alt() {
#expect(Hilfen.spielplan(#"{"modus":"uebung","tische":2}"#)?.formate == [.cash: 2])
}
@Test("Namen und Reihenfolge wie lesen/formate.py")
func namen() {
#expect(SpielFormat.allCases.map(\.rawValue) == ["cash", "aof", "bombpot", "turnier", "kpoker", "vip", "freeroll"])
#expect(SpielFormat.aof.name == "All-In or Fold")
}
}
@Suite("Vergleich je Format in den Ergebnissen (wachstum.je_format, bestes_format)")
struct FormatVergleichSpec {
@Test("je Format mit Spanne, das Urteil mit Grund")
func vergleich() {
let k = Hilfen.kurven(#"""
{"je_format":[{"format":"aof","name":"All-In or Fold","haende":40,"netto_bb":420,"bb100":1050.0,"unten":900.0,"oben":1200.0},
{"format":"cash","name":"Cash","haende":40,"netto_bb":-80,"bb100":-200.0,"unten":-260.0,"oben":-140.0}],
"bestes_format":{"format":"aof","grund":"aof liegt mit 95 % Sicherheit vorn"}}
"""#)
#expect(k?.jeFormat.map(\.format) == ["aof", "cash"])
#expect(k?.jeFormat.first?.unten == 900)
#expect(k?.bestesFormat?.format == "aof")
#expect(k?.bestesFormat?.grund.contains("95") == true)
}
@Test("ohne Urteil: format nil, Grund bleibt")
func ohneUrteil() {
let k = Hilfen.kurven(#"{"je_format":[],"bestes_format":{"format":null,"grund":"zu wenig Hände für ein Urteil"}}"#)
#expect(k?.bestesFormat?.format == nil)
#expect(k?.bestesFormat?.grund == "zu wenig Hände für ein Urteil")
}
}