package assessment import ( "errors" "testing" ) func TestScoreProducesStableRIASECCode(t *testing.T) { answers := make(map[string]int, len(Questions)) preference := map[Dimension]int{ Realistic: 2, Investigative: 5, Artistic: 4, Social: 3, Enterprising: 1, Conventional: 2, } for _, question := range Questions { answers[question.ID] = preference[question.Dimension] } result, err := Score(answers, true) if err != nil { t.Fatalf("Score returned an error: %v", err) } if result.Code != "IAS" { t.Fatalf("code = %q, want IAS", result.Code) } if result.Completeness != 100 || result.Confidence != "higher" { t.Fatalf("unexpected completeness/confidence: %d/%s", result.Completeness, result.Confidence) } if !result.ResearchUseOnly { t.Fatal("exploratory assessment must retain its research-use notice") } } func TestScoreRejectsIncompleteAndInvalidAnswers(t *testing.T) { if _, err := Score(map[string]int{"r01": 5}, true); !errors.Is(err, ErrIncomplete) { t.Fatalf("incomplete assessment error = %v, want ErrIncomplete", err) } if _, err := Score(map[string]int{"r01": 6}, false); err == nil { t.Fatal("out-of-range answer was accepted") } if _, err := Score(map[string]int{"not-a-question": 3}, false); err == nil { t.Fatal("unknown question was accepted") } } func TestNextQuestionBalancesDimensions(t *testing.T) { answers := map[string]int{"r01": 4} next, ok := NextQuestion(answers) if !ok { t.Fatal("NextQuestion unexpectedly reported completion") } if next.Dimension != Investigative { t.Fatalf("next dimension = %q, want %q", next.Dimension, Investigative) } for _, question := range Questions { answers[question.ID] = 3 } if _, ok := NextQuestion(answers); ok { t.Fatal("NextQuestion returned an item after completion") } }