day20: more reading

This commit is contained in:
efim
2023-12-20 08:10:10 +00:00
parent 9dbc2ca205
commit 4974127cef
7 changed files with 202 additions and 85 deletions

View File

@@ -16,7 +16,7 @@ func TestParseFlipFlop(t *testing.T) {
func TestParseBroadcast(t *testing.T) {
broadcastLine := "broadcaster -> a, b, c"
if !isLineBroadcast(broadcastLine) {
if !IsLineBroadcast(broadcastLine) {
t.Error("expected line to pass broadcast check")
}
module := ParseBroadcast(broadcastLine)
@@ -29,16 +29,24 @@ func TestParseBroadcast(t *testing.T) {
func TestParseConjunction(t *testing.T) {
conjunctionLine := "&inv -> b"
if !isLineConjunction(conjunctionLine) {
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"}) {
moduleAsExpected := module.Name != "inv" || slices.Equal(module.OutputNames, []string{"b"})
if !moduleAsExpected {
t.Fail()
}
}
func TestPanic(t *testing.T) {
panic("hehe")
func TestReadManyModules(t *testing.T) {
filename := "example1"
modules := ReadModules(filename)
t.Logf("> read example1:\n%+v", modules)
filename2 := "example2"
modules2 := ReadModules(filename2)
t.Logf("> read example2:\n%+v", modules2)
}