// License: GPLv3 Copyright: 2026, Kovid Goyal, package hints import "testing" func TestNextSelection(t *testing.T) { cases := []struct { pos, marks, delta, expected int }{ // Nothing selected yet: down selects the first choice, up the last one {-1, 3, 0, 0}, {-1, 3, 1, 0}, {-1, 3, -1, 2}, // Moving past either end wraps around {0, 3, 1, 1}, {2, 3, 1, 0}, {0, 3, -1, 2}, {1, 1, 2, 0}, {0, 3, 4, 1}, {0, 3, -4, 2}, // A stale position falls back to the first choice {5, 3, 1, 0}, // An empty list has nothing to select {-1, 0, 1, -1}, {0, 0, -1, -1}, } for _, c := range cases { if got := next_selection(c.pos, c.marks, c.delta); got != c.expected { t.Fatalf("next_selection(%d, %d, %d) = %d, expected %d", c.pos, c.marks, c.delta, got, c.expected) } } }