Files
advent-of-code-2025/day5/main_test.go
2025-12-06 16:50:12 +02:00

69 lines
961 B
Go

package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test_compactedRanges(t *testing.T) {
tests := []struct {
name string // description of this test case
ranges []idsRange
want []idsRange
}{
{
name: "single",
ranges: []idsRange{
{0, 10},
},
want: []idsRange{
{0, 10},
},
},
{
name: "identical",
ranges: []idsRange{
{0, 10},
{0, 10},
{0, 10},
{20, 30},
{20, 30},
},
want: []idsRange{
{0, 10},
{20, 30},
},
},
{
name: "simple",
ranges: []idsRange{
{0, 10},
{2, 11},
{20, 30},
},
want: []idsRange{
{0, 11},
{20, 30},
},
},
{
name: "swallows",
ranges: []idsRange{
{0, 10},
{2, 8},
{20, 30},
},
want: []idsRange{
{0, 10},
{20, 30},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
assert.Equal(t, tt.want, compactedRanges(tt.ranges))
})
}
}