Advent tests

Support tests. Pretty self explanatory.

Also, this is pretty tiring, I may continue tweak out future tests at a future date but not tomorrow.

Tests for day 12

package problems

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

func Test_Day12(t *testing.T) {
	test_cases := []struct {
		input           []string
		part_one_assert int
		part_two_assert int
	}{
		{
			input: []string{
				"Sabqponm",
				"abcryxxl",
				"accszExk",
				"acctuvwj",
				"abdefghi",
			},
			part_one_assert: 31,
			part_two_assert: 29,
		},
	}

	for _, test := range test_cases {
		in := day12{
			lines: test.input,
		}
		assert.Equal(t, test.part_one_assert, in.part_one())
		assert.Equal(t, test.part_two_assert, in.part_two())
	}
}

tests for day 13

package problems

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

func Test_Day13(t *testing.T) {
	test_cases := []struct {
		input           []string
		part_one_assert int
		part_two_assert int
	}{
		{
			input: []string{
				"[1,1,3,1,1]",
				"[1,1,5,1,1]",
				"",
				"[[1],[2,3,4]]",
				"[[1],4]",
				"",
				"[9]",
				"[[8,7,6]]",
				"",
				"[[4,4],4,4]",
				"[[4,4],4,4,4]",
				"",
				"[7,7,7,7]",
				"[7,7,7]",
				"",
				"[]",
				"[3]",
				"",
				"[[[]]]",
				"[[]]",
				"",
				"[1,[2,[3,[4,[5,6,7]]]],8,9]",
				"[1,[2,[3,[4,[5,6,0]]]],8,9]",
			},
			part_one_assert: 13,
			part_two_assert: 140,
		},
	}

	for _, test := range test_cases {
		in := day13{
			lines: test.input,
		}
		assert.Equal(t, test.part_one_assert, in.part_one())
		assert.Equal(t, test.part_two_assert, in.part_two())
	}
}

tests for day 14

package problems

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

func Test_Day14(t *testing.T) {
	test_cases := []struct {
		input           []string
		part_one_assert int
		part_two_assert int
	}{
		{
			input: []string{
				"498,4 -> 498,6 -> 496,6",
				"503,4 -> 502,4 -> 502,9 -> 494,9",
			},
			part_one_assert: 24,
			part_two_assert: 93,
		},
	}

	for _, test := range test_cases {
		in := day14{
			lines: test.input,
		}
		assert.Equal(t, test.part_one_assert, in.part_one())
		assert.Equal(t, test.part_two_assert, in.part_two())
	}
}

tests for day 15

package problems

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

func Test_Day15(t *testing.T) {
	test_cases := []struct {
		input           []string
		part_one_assert int
		part_two_assert int
	}{
		{
			input: []string{
				"Sensor at x=2, y=18: closest beacon is at x=-2, y=15",
				"Sensor at x=9, y=16: closest beacon is at x=10, y=16",
				"Sensor at x=13, y=2: closest beacon is at x=15, y=3",
				"Sensor at x=12, y=14: closest beacon is at x=10, y=16",
				"Sensor at x=10, y=20: closest beacon is at x=10, y=16",
				"Sensor at x=14, y=17: closest beacon is at x=10, y=16",
				"Sensor at x=8, y=7: closest beacon is at x=2, y=10",
				"Sensor at x=2, y=0: closest beacon is at x=2, y=10",
				"Sensor at x=0, y=11: closest beacon is at x=2, y=10",
				"Sensor at x=20, y=14: closest beacon is at x=25, y=17",
				"Sensor at x=17, y=20: closest beacon is at x=21, y=22",
				"Sensor at x=16, y=7: closest beacon is at x=15, y=3",
				"Sensor at x=14, y=3: closest beacon is at x=15, y=3",
				"Sensor at x=20, y=1: closest beacon is at x=15, y=3",
			},
			part_one_assert: 26,
			part_two_assert: 56000011,
		},
	}

	t.Setenv("ENV", "test")

	for _, test := range test_cases {
		in := day15{
			lines: test.input,
		}

		assert.Equal(t, test.part_one_assert, in.part_one())
		assert.Equal(t, test.part_two_assert, in.part_two())
	}
}