package effort import "testing" func TestParse(t *testing.T) { cases := []struct { in string want Level wantErr bool }{ {"", Default, false}, {"low", Low, false}, {" LOW ", Low, false}, {"fast", Low, false}, {"medium", Medium, false}, {"default", Medium, false}, {"high", High, false}, {"deep", High, false}, {"extra", Extra, false}, {"thorough", Extra, false}, {"max", Max, false}, {"ultra", Max, false}, {"bogus", "", true}, } for _, tc := range cases { got, err := Parse(tc.in) if tc.wantErr { if err == nil { t.Errorf("Parse(%q) = %q, nil; want an error", tc.in, got) } continue } if err != nil { t.Errorf("Parse(%q) returned unexpected error: %v", tc.in, err) continue } if got != tc.want { t.Errorf("Parse(%q) = %q, want %q", tc.in, got, tc.want) } } } func TestValid(t *testing.T) { for _, l := range All { if !l.Valid() { t.Errorf("%q should be Valid", l) } } if Level("bogus").Valid() { t.Error(`Level("bogus").Valid() = true, want false`) } if Level("").Valid() { t.Error(`Level("").Valid() = true, want false`) } } func TestResolveOrdering(t *testing.T) { // Depth should be monotonic across the five levels for every knob // that's supposed to scale with effort — a regression here (e.g. // Extra accidentally configured with a smaller budget than High) // would quietly break the "arbitrate between speed and precision" // contract the whole feature exists to provide. levels := []Level{Low, Medium, High, Extra, Max} var prevRounds, prevBudget, prevParallel int for i, l := range levels { p := l.Resolve() if p.Level != l { t.Errorf("%s.Resolve().Level = %s, want %s", l, p.Level, l) } if i > 0 { if p.MaxRounds < prevRounds { t.Errorf("%s.MaxRounds (%d) < %s.MaxRounds (%d); want non-decreasing", l, p.MaxRounds, levels[i-1], prevRounds) } if p.ContextBudgetChars < prevBudget { t.Errorf("%s.ContextBudgetChars (%d) < %s.ContextBudgetChars (%d); want non-decreasing", l, p.ContextBudgetChars, levels[i-1], prevBudget) } if p.MaxParallelSubagents < prevParallel { t.Errorf("%s.MaxParallelSubagents (%d) < %s.MaxParallelSubagents (%d); want non-decreasing", l, p.MaxParallelSubagents, levels[i-1], prevParallel) } } prevRounds, prevBudget, prevParallel = p.MaxRounds, p.ContextBudgetChars, p.MaxParallelSubagents } } func TestResolveInvalidFallsBackToMedium(t *testing.T) { got := Level("not-a-real-level").Resolve() want := Medium.Resolve() if got != want { t.Errorf("invalid Level.Resolve() = %+v, want Medium's profile %+v", got, want) } } func TestLowHasOutputCapOthersDont(t *testing.T) { if Low.Resolve().NumPredictCap == 0 { t.Error("Low should set a NumPredictCap") } for _, l := range []Level{Medium, High, Extra, Max} { if got := l.Resolve().NumPredictCap; got != 0 { t.Errorf("%s.NumPredictCap = %d, want 0 (uncapped)", l, got) } } }