day20, starting to read in data
with using tests as entry points for checking things
This commit is contained in:
44
day20/modules_test.go
Normal file
44
day20/modules_test.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package day20
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParseFlipFlop(t *testing.T) {
|
||||
flipFlopLine := "%a -> inv, con"
|
||||
if !IsLineFlipFlop(flipFlopLine) {
|
||||
t.Errorf("line '%s' should be flip flop\n", flipFlopLine)
|
||||
}
|
||||
module := ParseFlipFlop(flipFlopLine)
|
||||
t.Logf("got module %+v\n", module)
|
||||
}
|
||||
|
||||
func TestParseBroadcast(t *testing.T) {
|
||||
broadcastLine := "broadcaster -> a, b, c"
|
||||
if !isLineBroadcast(broadcastLine) {
|
||||
t.Error("expected line to pass broadcast check")
|
||||
}
|
||||
module := ParseBroadcast(broadcastLine)
|
||||
t.Logf("got module %+v\n", module)
|
||||
|
||||
if !slices.Equal(module.OutputNames, []string{"a", "b", "c"}) {
|
||||
t.Errorf("got unexpected outputs: %+v\n", module.OutputNames)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseConjunction(t *testing.T) {
|
||||
conjunctionLine := "&inv -> b"
|
||||
if !isLineConjunction(conjunctionLine) {
|
||||
t.Errorf("line '%s' should be flip flop\n", conjunctionLine)
|
||||
}
|
||||
module := ParseConjunction(conjunctionLine)
|
||||
t.Logf("got module %+v\n", module)
|
||||
if module.Name != "inv" || slices.Equal(module.OutputNames, []string{"b"}) {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestPanic(t *testing.T) {
|
||||
panic("hehe")
|
||||
}
|
||||
Reference in New Issue
Block a user