refactor: use shared variable for input
This commit is contained in:
@@ -2,20 +2,20 @@ package main
|
|||||||
|
|
||||||
import "testing"
|
import "testing"
|
||||||
|
|
||||||
|
var testInput = []int{1721, 979, 366, 299, 675, 1456}
|
||||||
|
|
||||||
func TestPartOne(t *testing.T) {
|
func TestPartOne(t *testing.T) {
|
||||||
input := []int{1721, 979, 366, 299, 675, 1456}
|
|
||||||
expected := 514579
|
expected := 514579
|
||||||
got := PartOne(input)
|
got := PartOne(testInput)
|
||||||
if got != expected {
|
if got != expected {
|
||||||
t.Errorf("PartOne(%v) = %d, want %d", input, got, expected)
|
t.Errorf("PartOne(%v) = %d, want %d", testInput, got, expected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPartTwo(t *testing.T) {
|
func TestPartTwo(t *testing.T) {
|
||||||
input := []int{1721, 979, 366, 299, 675, 1456}
|
|
||||||
expected := 241861950
|
expected := 241861950
|
||||||
got := PartTwo(input)
|
got := PartTwo(testInput)
|
||||||
if got != expected {
|
if got != expected {
|
||||||
t.Errorf("PartTwo(%v) = %d, want %d", input, got, expected)
|
t.Errorf("PartTwo(%v) = %d, want %d", testInput, got, expected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,28 +2,24 @@ package main
|
|||||||
|
|
||||||
import "testing"
|
import "testing"
|
||||||
|
|
||||||
func TestPartOne(t *testing.T) {
|
var testInput = []string{
|
||||||
input := []string{
|
|
||||||
"1-3 a: abcde",
|
"1-3 a: abcde",
|
||||||
"1-3 b: cdefg",
|
"1-3 b: cdefg",
|
||||||
"2-9 c: ccccccccc",
|
"2-9 c: ccccccccc",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPartOne(t *testing.T) {
|
||||||
expected := 2
|
expected := 2
|
||||||
got := PartOne(input)
|
got := PartOne(testInput)
|
||||||
if got != expected {
|
if got != expected {
|
||||||
t.Errorf("PartOne(%v) = %d, want %d", input, got, expected)
|
t.Errorf("PartOne(%v) = %d, want %d", testInput, got, expected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPartTwo(t *testing.T) {
|
func TestPartTwo(t *testing.T) {
|
||||||
input := []string{
|
|
||||||
"1-3 a: abcde",
|
|
||||||
"1-3 b: cdefg",
|
|
||||||
"2-9 c: ccccccccc",
|
|
||||||
}
|
|
||||||
expected := 1
|
expected := 1
|
||||||
got := PartTwo(input)
|
got := PartTwo(testInput)
|
||||||
if got != expected {
|
if got != expected {
|
||||||
t.Errorf("PartTwo(%v) = %d, want %d", input, got, expected)
|
t.Errorf("PartTwo(%v) = %d, want %d", testInput, got, expected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,7 @@ package main
|
|||||||
|
|
||||||
import "testing"
|
import "testing"
|
||||||
|
|
||||||
func TestPartOne(t *testing.T) {
|
var testInput = []string{
|
||||||
input := []string{
|
|
||||||
"..##.......",
|
"..##.......",
|
||||||
"#...#...#..",
|
"#...#...#..",
|
||||||
".#....#..#.",
|
".#....#..#.",
|
||||||
@@ -15,30 +14,19 @@ func TestPartOne(t *testing.T) {
|
|||||||
"#.##...#...",
|
"#.##...#...",
|
||||||
"#...##....#",
|
"#...##....#",
|
||||||
".#..#...#.#",
|
".#..#...#.#",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPartOne(t *testing.T) {
|
||||||
expected := 7
|
expected := 7
|
||||||
got := PartOne(input)
|
got := PartOne(testInput)
|
||||||
if got != expected {
|
if got != expected {
|
||||||
t.Errorf("PartOne() = %d, want %d", got, expected)
|
t.Errorf("PartOne() = %d, want %d", got, expected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPartTwo(t *testing.T) {
|
func TestPartTwo(t *testing.T) {
|
||||||
input := []string{
|
|
||||||
"..##.......",
|
|
||||||
"#...#...#..",
|
|
||||||
".#....#..#.",
|
|
||||||
"..#.#...#.#",
|
|
||||||
".#...##..#.",
|
|
||||||
"..#.##.....",
|
|
||||||
".#.#.#....#",
|
|
||||||
".#........#",
|
|
||||||
"#.##...#...",
|
|
||||||
"#...##....#",
|
|
||||||
".#..#...#.#",
|
|
||||||
}
|
|
||||||
expected := 336
|
expected := 336
|
||||||
got := PartTwo(input)
|
got := PartTwo(testInput)
|
||||||
if got != expected {
|
if got != expected {
|
||||||
t.Errorf("PartTwo() = %d, want %d", got, expected)
|
t.Errorf("PartTwo() = %d, want %d", got, expected)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user