Skip to content
quarry Artifact [6e10de6356]
Login

Artifact [6e10de6356]

Artifact 6e10de6356075a529c2ba5be4d50eb66f78957899c008a197514442bd39b453b:


package api

import (
	"slices"
	"testing"
)

// ln= reads every shape fossil's does and ignores what is not a line
// number, so a mangled address still opens the file.
func TestParseLineRanges(t *testing.T) {
	for _, c := range []struct {
		in   string
		want []LineRange
	}{
		{"193", []LineRange{{193, 193}}},
		{"193-205", []LineRange{{193, 205}}},
		{"205-193", []LineRange{{193, 205}}},
		{"193-198,210-214", []LineRange{{193, 198}, {210, 214}}},
		{"210-214+193-198", []LineRange{{193, 198}, {210, 214}}},
		{"1-5,4-9,10", []LineRange{{1, 10}}},
		{"x,0,-3,7-y,12", []LineRange{{12, 12}}},
		{"", nil},
	} {
		if got := parseLineRanges(c.in); !slices.Equal(got, c.want) {
			t.Errorf("FAIL: ln=%q: got %v, want %v", c.in, got, c.want)
		}
	}
}