package confline import "testing" func TestCommentIndex(t *testing.T) { tests := []struct { name string line string whitespace bool want int }{ {name: "plain", line: "value # comment", whitespace: true, want: 6}, {name: "quoted hash", line: `show-text "a # b" # comment`, whitespace: true, want: 18}, {name: "single quoted hash", line: `value='a # b' # comment`, whitespace: true, want: 14}, {name: "escaped hash", line: `value=a\#b # comment`, whitespace: true, want: 11}, {name: "color", line: "color=#FF8232", whitespace: true, want: -1}, {name: "color without whitespace rule", line: "color=#FF8232", want: 6}, } for _, test := range tests { t.Run(test.name, func(t *testing.T) { if got := CommentIndex(test.line, test.whitespace); got != test.want { t.Fatalf("CommentIndex(%q) = %d, want %d", test.line, got, test.want) } }) } }