@@ -0,0 +1,68 @@
6+ "github.com/stretchr/testify/require"
8+ "github.com/charmbracelet/x/powernap/pkg/lsp/protocol"
11+func TestRangesOverlap(t *testing.T) {
21+ name: "adjacent ranges do not overlap",
23+ Start: protocol.Position{Line: 0, Character: 0},
24+ End: protocol.Position{Line: 0, Character: 5},
27+ Start: protocol.Position{Line: 0, Character: 5},
28+ End: protocol.Position{Line: 0, Character: 10},
33+ name: "overlapping ranges",
35+ Start: protocol.Position{Line: 0, Character: 0},
36+ End: protocol.Position{Line: 0, Character: 8},
39+ Start: protocol.Position{Line: 0, Character: 5},
40+ End: protocol.Position{Line: 0, Character: 10},
45+ name: "non-overlapping with gap",
47+ Start: protocol.Position{Line: 0, Character: 0},
48+ End: protocol.Position{Line: 0, Character: 3},
51+ Start: protocol.Position{Line: 0, Character: 7},
52+ End: protocol.Position{Line: 0, Character: 10},
58+ for _, tt := range tests {
59+ t.Run(tt.name, func(t *testing.T) {
61+ got := rangesOverlap(tt.r1, tt.r2)
62+ require.Equal(t, tt.want, got, "rangesOverlap(r1, r2)")
63+ // Overlap should be symmetric
64+ got2 := rangesOverlap(tt.r2, tt.r1)
65+ require.Equal(t, tt.want, got2, "rangesOverlap(r2, r1) symmetry")