code_test.go 538 B

12345678910111213141516171819202122232425
  1. package main
  2. import "testing"
  3. func TestPart1(t *testing.T) {
  4. crabs, orderedCrabs := readInput("./testinput")
  5. if len(crabs) == 0 || len(orderedCrabs) == 0 {
  6. t.Error("Could not read input")
  7. }
  8. if calculate(crabs, orderedCrabs, costPart1) != 37 {
  9. t.Error("Part 1 failed")
  10. }
  11. }
  12. func TestPart2(t *testing.T) {
  13. crabs, orderedCrabs := readInput("./testinput")
  14. if len(crabs) == 0 || len(orderedCrabs) == 0 {
  15. t.Error("Could not read input")
  16. }
  17. if calculate(crabs, orderedCrabs, costPart2) != 168 {
  18. t.Error("Part 2 failed")
  19. }
  20. }