Files
advent-of-code-2021/day-1/main_test.go
T

30 lines
638 B
Go
Raw Normal View History

2021-12-01 15:31:51 -05:00
package main
import (
2021-12-08 16:31:05 -05:00
"AoC2021/utils/assert"
2021-12-01 15:31:51 -05:00
"testing"
)
func TestPrintPip(t *testing.T) {
DEBUG = false
str := GetPip(1, 1, 1, 100)
2021-12-08 16:31:05 -05:00
assert.EqualsStr(t, str, "", "Should return an empty string")
2021-12-01 15:31:51 -05:00
DEBUG = true
cases := []struct {
first, previous, current, total int
expected, msg string
}{
{-1, -1, -1, -1, ".", ""},
{-1, 0, 0, 42, ".", ""},
{100, 100, 200, 42, "+", ""},
{100, 200, 100, 42, "-", ""},
{100, 100, 100, 100, ".\n", "should include newline"},
}
for _, c := range cases {
str := GetPip(c.first, c.previous, c.current, c.total)
2021-12-08 16:31:05 -05:00
assert.EqualsStr(t, str, c.expected, c.msg)
2021-12-01 15:31:51 -05:00
}
}