Day 1: Part 1

This commit is contained in:
James Griffin
2020-12-02 12:04:50 -04:00
parent 87514a8427
commit d7f1ba55ed
7 changed files with 324 additions and 0 deletions

35
one/day_one_test.go Normal file
View File

@@ -0,0 +1,35 @@
package one
import "testing"
func Test_expenseReport_load(t *testing.T) {
report := expenseReport{}
if err := report.load("sample.txt"); err != nil {
t.Log(err)
t.FailNow()
}
if len(report.expenses) != 6 {
t.Logf("Expected 6 expenses, Got %d expesnes", len(report.expenses))
t.FailNow()
}
}
func Test_expenseReport_searchAndMultiply(t *testing.T) {
report := expenseReport{
expenses: []int{
1721,
979,
366,
299,
675,
1456,
},
}
result, _ := report.searchAndMultiply(2020)
if result != 514579 {
t.Logf("Expected 514579, Got %d", result)
t.FailNow()
}
}