2025-12-23 08:18:01 -06:00
|
|
|
package shape_test
|
|
|
|
|
|
|
|
|
|
import (
|
2025-12-24 08:35:14 -06:00
|
|
|
"strings"
|
2025-12-23 08:18:01 -06:00
|
|
|
"testing"
|
2025-12-24 08:35:14 -06:00
|
|
|
|
|
|
|
|
"github.com/StevanFreeborn/advent-of-code-2025/cmd/12/shape"
|
2025-12-23 08:18:01 -06:00
|
|
|
)
|
|
|
|
|
|
2025-12-24 08:35:14 -06:00
|
|
|
func TestGenerateVariants(t *testing.T) {
|
|
|
|
|
t.Run("works for shape 0", func(t *testing.T) {
|
|
|
|
|
expectedVariants := [][]string{
|
|
|
|
|
{
|
|
|
|
|
"###",
|
|
|
|
|
"##.",
|
|
|
|
|
"##.",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"###",
|
|
|
|
|
".##",
|
|
|
|
|
".##",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"###",
|
|
|
|
|
"###",
|
|
|
|
|
"#..",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"###",
|
|
|
|
|
"###",
|
|
|
|
|
"..#",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
".##",
|
|
|
|
|
".##",
|
|
|
|
|
"###",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"##.",
|
|
|
|
|
"##.",
|
|
|
|
|
"###",
|
|
|
|
|
},
|
|
|
|
|
}
|
2025-12-23 08:18:01 -06:00
|
|
|
|
2025-12-24 08:35:14 -06:00
|
|
|
lines := []string{
|
|
|
|
|
"0:",
|
|
|
|
|
"###",
|
|
|
|
|
"##.",
|
|
|
|
|
"##.",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
shape := shape.From(lines)
|
|
|
|
|
|
|
|
|
|
result := shape.GenerateVariants()
|
|
|
|
|
|
|
|
|
|
for _, ev := range expectedVariants {
|
|
|
|
|
expected := strings.Join(ev, "\n")
|
|
|
|
|
|
|
|
|
|
found := false
|
|
|
|
|
|
|
|
|
|
for _, v := range result {
|
|
|
|
|
if strings.TrimSpace(v.String()) == expected {
|
|
|
|
|
found = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if found == false {
|
|
|
|
|
t.Errorf("expected to find variant but did not:\n%v", expected)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("works for shape 1", func(t *testing.T) {
|
|
|
|
|
expectedVariants := [][]string{
|
|
|
|
|
{
|
|
|
|
|
"###",
|
|
|
|
|
"##.",
|
|
|
|
|
".##",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
".##",
|
|
|
|
|
"###",
|
|
|
|
|
"#.#",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"##.",
|
|
|
|
|
".##",
|
|
|
|
|
"###",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"#.#",
|
|
|
|
|
"###",
|
|
|
|
|
"##.",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"###",
|
|
|
|
|
".##",
|
|
|
|
|
"##.",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"##.",
|
|
|
|
|
"###",
|
|
|
|
|
"#.#",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"##.",
|
|
|
|
|
"###",
|
|
|
|
|
"#.#",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
".##",
|
|
|
|
|
"##.",
|
|
|
|
|
"###",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"#.#",
|
|
|
|
|
"###",
|
|
|
|
|
".##",
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lines := []string{
|
|
|
|
|
"0:",
|
|
|
|
|
"###",
|
|
|
|
|
"##.",
|
|
|
|
|
".##",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
shape := shape.From(lines)
|
|
|
|
|
|
|
|
|
|
result := shape.GenerateVariants()
|
|
|
|
|
|
|
|
|
|
for _, ev := range expectedVariants {
|
|
|
|
|
expected := strings.Join(ev, "\n")
|
|
|
|
|
|
|
|
|
|
found := false
|
|
|
|
|
|
|
|
|
|
for _, v := range result {
|
|
|
|
|
if strings.TrimSpace(v.String()) == expected {
|
|
|
|
|
found = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if found == false {
|
|
|
|
|
t.Errorf("expected to find variant but did not:\n%v", expected)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
2025-12-23 08:18:01 -06:00
|
|
|
}
|