042a1d4773
* introduced central package registry by package init function * dynamic registration of routes, model, migrations and initializers. * setting a docker compose project name to prevent shutdown of other containers with the same (composer)name * ai documentation * app template * Create tests for ALL API entpoints in ALL packages Based on current data. Ensure that all API endpoints used in frontend are tested. These tests are crucial for the next refactoring tasks. * adopting agent instructions for a more consistent coding style * added desired module layout and debugging information * Fix All Failing tests All failing tests are fixed now that makes the refactoring more easy since all tests must pass * restored routes for maintenance * added common translations * added new tests for API Endpoint * Merge branch 'separate_business_logic' * added lern and skill improvement cost editing * Set Docker image tag when building to prevent rebuild when nothing has changed * add and remove PP for Weaponskill fixed * add and remove PP for same named skills fixed * add new task
75 lines
1.9 KiB
Go
75 lines
1.9 KiB
Go
package character
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestGetSpecialAbilityByRoll(t *testing.T) {
|
|
testCases := []struct {
|
|
roll int
|
|
expected string
|
|
modifier int
|
|
}{
|
|
{1, "Sehen", -2},
|
|
{5, "Sehen", -2},
|
|
{6, "Hören", -2},
|
|
{16, "Sechster Sinn", 2},
|
|
{25, "Sehen", 2},
|
|
{55, "Nachtsicht", 2},
|
|
{60, "Gute Reflexe", 9},
|
|
{65, "Richtungssinn", 12},
|
|
{70, "Robustheit", 9},
|
|
{75, "Schmerzunempfindlichkeit", 9},
|
|
{80, "Trinken", 12},
|
|
{85, "Wachgabe", 6},
|
|
{90, "Wahrnehmung", 8},
|
|
{95, "Einprägen", 4},
|
|
{96, "Berserkergang", 0},
|
|
{99, "Berserkergang", 0},
|
|
{100, "Freie Wahl", 0},
|
|
}
|
|
|
|
for _, tc := range testCases {
|
|
ability, err := GetSpecialAbilityByRoll(tc.roll)
|
|
if err != nil {
|
|
t.Errorf("Unerwarteter Fehler für Wurf %d: %v", tc.roll, err)
|
|
continue
|
|
}
|
|
if ability.Name != tc.expected {
|
|
t.Errorf("Für Wurf %d: erwartet '%s', erhalten '%s'", tc.roll, tc.expected, ability.Name)
|
|
}
|
|
if ability.Modifier != tc.modifier {
|
|
t.Errorf("Für Wurf %d: erwarteter Modifier %d, erhalten %d", tc.roll, tc.modifier, ability.Modifier)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestGetSpecialAbilityByRollInvalidInput(t *testing.T) {
|
|
invalidRolls := []int{0, -1, 101, 1000}
|
|
|
|
for _, roll := range invalidRolls {
|
|
_, err := GetSpecialAbilityByRoll(roll)
|
|
if err == nil {
|
|
t.Errorf("Erwartete Fehler für ungültigen Wurf %d, aber keinen erhalten", roll)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestGetAllSpecialAbilities(t *testing.T) {
|
|
abilities := GetAllSpecialAbilities()
|
|
|
|
if len(abilities) != 18 {
|
|
t.Errorf("Erwartete 18 besondere Fähigkeiten, erhalten %d", len(abilities))
|
|
}
|
|
|
|
// Teste, dass alle Bereiche lückenlos von 1-100 abgedeckt sind
|
|
for i, ability := range abilities {
|
|
if i == 0 && ability.RangeStart != 1 {
|
|
t.Errorf("Erster Bereich sollte bei 1 starten, startet bei %d", ability.RangeStart)
|
|
}
|
|
if i == len(abilities)-1 && ability.RangeEnd != 100 {
|
|
t.Errorf("Letzter Bereich sollte bei 100 enden, endet bei %d", ability.RangeEnd)
|
|
}
|
|
}
|
|
}
|