Day 1: Part 1
This commit is contained in:
35
one/day_one_test.go
Normal file
35
one/day_one_test.go
Normal 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()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user