56 lines
1.3 KiB
Go
56 lines
1.3 KiB
Go
package main
|
|
|
|
import "testing"
|
|
|
|
type highestTest struct {
|
|
bank string
|
|
start int
|
|
end int
|
|
expected, expectedIndex int
|
|
}
|
|
|
|
var highestTests = []highestTest{
|
|
{"999", 0, 3, 9, 0},
|
|
{"919", 0, 3, 9, 0},
|
|
{"919", 1, 3, 9, 2},
|
|
{"818181911112111", 0, 4, 8, 0},
|
|
{"818181911112111", 1, 5, 8, 2},
|
|
{"818181911112111", 3, 6, 8, 4},
|
|
{"818181911112111", 5, 7, 9, 6},
|
|
}
|
|
|
|
func TestHhigest(t *testing.T) {
|
|
for _, test := range highestTests {
|
|
highest, index := highestEarly(parseBank(test.bank), test.start, test.end)
|
|
|
|
if highest != test.expected {
|
|
t.Errorf("Expected %d got %d for bank %v", test.expected, highest, test.bank)
|
|
}
|
|
|
|
if index != test.expectedIndex {
|
|
t.Errorf("Expected %d got %d for bank %v", test.expectedIndex, index, test.bank)
|
|
}
|
|
}
|
|
}
|
|
|
|
type joltageTest struct {
|
|
bank string
|
|
expected int
|
|
}
|
|
|
|
var joltageTests = []joltageTest{
|
|
{"987654321111111", 987654321111},
|
|
{"811111111111119", 811111111119},
|
|
{"234234234234278", 434234234278},
|
|
{"818181911112111", 888911112111},
|
|
}
|
|
|
|
func TestJoltage(t *testing.T) {
|
|
for _, test := range joltageTests {
|
|
out := _joltage(parseBank(test.bank))
|
|
|
|
if out != test.expected {
|
|
t.Errorf("Expected %d got %d for bank %v", test.expected, out, test.bank)
|
|
}
|
|
}
|
|
}
|