day20, example 2 first four steps pass
This commit is contained in:
76
day20/propagation_test.go
Normal file
76
day20/propagation_test.go
Normal file
@@ -0,0 +1,76 @@
|
||||
package day20
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPropagateButtonPressExample1(t *testing.T) {
|
||||
filename := "example1"
|
||||
modules := ReadModules(filename)
|
||||
t.Log("got modules:\n", modules)
|
||||
|
||||
low, high := PropagateButtonPress(modules)
|
||||
t.Logf("got low %d and high %d\n", low, high)
|
||||
t.Log("modules after single button press:\n", modules)
|
||||
|
||||
success := low == 8 && high == 4
|
||||
if !success {
|
||||
t.Errorf("expected low 8 got %d, high 4 got %d", low, high)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPropagateButtonPressExample2(t *testing.T) {
|
||||
filename := "example2"
|
||||
modules := ReadModules(filename)
|
||||
t.Log("got modules:\n", modules)
|
||||
InitStuffs(modules)
|
||||
|
||||
low, high := PropagateButtonPress(modules)
|
||||
t.Logf("got low %d and high %d\n", low, high)
|
||||
t.Log("modules after single button press:\n", modules)
|
||||
|
||||
success := low == 4 && high == 4
|
||||
if !success {
|
||||
t.Errorf("expected low 4 got %d, high 4 got %d", low, high)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPropagateButtonPressExample2FourSteps(t *testing.T) {
|
||||
filename := "example2"
|
||||
modules := ReadModules(filename)
|
||||
t.Log("got modules:\n", modules)
|
||||
InitStuffs(modules)
|
||||
|
||||
low, high := PropagateButtonPress(modules)
|
||||
t.Logf("got low %d and high %d\n", low, high)
|
||||
t.Log("#1 button press:\n", modules)
|
||||
success := low == 4 && high == 4
|
||||
if !success {
|
||||
t.Errorf("expected low 4 got %d, high 4 got %d", low, high)
|
||||
}
|
||||
|
||||
low, high = PropagateButtonPress(modules)
|
||||
t.Logf("got low %d and high %d\n", low, high)
|
||||
t.Log("#2 button press:\n", modules)
|
||||
success = low == 4 && high == 2
|
||||
if !success {
|
||||
t.Errorf("expected low 4 got %d, high 2 got %d", low, high)
|
||||
}
|
||||
|
||||
low, high = PropagateButtonPress(modules)
|
||||
t.Logf("got low %d and high %d\n", low, high)
|
||||
t.Log("#3 button press:\n", modules)
|
||||
success = low == 5 && high == 3
|
||||
if !success {
|
||||
t.Errorf("expected low 5 got %d, high 3 got %d", low, high)
|
||||
}
|
||||
|
||||
low, high = PropagateButtonPress(modules)
|
||||
t.Logf("got low %d and high %d\n", low, high)
|
||||
t.Log("#4 button press:\n", modules)
|
||||
success = low == 4 && high == 2
|
||||
if !success {
|
||||
t.Errorf("expected low 4 got %d, high 2 got %d", low, high)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user