day20, modules state comparations

This commit is contained in:
efim
2023-12-20 09:58:40 +00:00
parent 00e60657fa
commit f538945dff
3 changed files with 51 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
package day20
import (
"log"
"testing"
)
@@ -41,6 +42,8 @@ func TestPropagateButtonPressExample2FourSteps(t *testing.T) {
t.Log("got modules:\n", modules)
InitStuffs(modules)
initialModulesState := ModulesState(modules)
low, high := PropagateButtonPress(modules)
t.Logf("got low %d and high %d\n", low, high)
t.Log("#1 button press:\n", modules)
@@ -56,6 +59,10 @@ func TestPropagateButtonPressExample2FourSteps(t *testing.T) {
if !success {
t.Errorf("expected low 4 got %d, high 2 got %d", low, high)
}
secondState := ModulesState(modules)
if initialModulesState == secondState {
t.Error("initial state should be different from second")
}
low, high = PropagateButtonPress(modules)
t.Logf("got low %d and high %d\n", low, high)
@@ -64,6 +71,10 @@ func TestPropagateButtonPressExample2FourSteps(t *testing.T) {
if !success {
t.Errorf("expected low 5 got %d, high 3 got %d", low, high)
}
thirdState := ModulesState(modules)
if initialModulesState == thirdState {
t.Error("initial state should be different from third")
}
low, high = PropagateButtonPress(modules)
t.Logf("got low %d and high %d\n", low, high)
@@ -73,4 +84,12 @@ func TestPropagateButtonPressExample2FourSteps(t *testing.T) {
t.Errorf("expected low 4 got %d, high 2 got %d", low, high)
}
lastState := ModulesState(modules)
log.Print("initial modules state:\n", initialModulesState)
log.Print("after 4 steps modules state:\n", lastState)
if initialModulesState != lastState {
t.Error("expected state to be same after 4 steps for example 2")
}
}