Skip to content

Commit

Permalink
fix missing ptrs
Browse files Browse the repository at this point in the history
  • Loading branch information
rohenaz committed Feb 8, 2023
1 parent dc01f7c commit 5c13f8b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 6 deletions.
1 change: 0 additions & 1 deletion bob.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ func (m MAP) FromTape(tape *bpu.Tape) error {

if len(tape.Cell) > 0 && tape.Cell[0].S != nil && *tape.Cell[0].S == Prefix {
m[Cmd] = *tape.Cell[1].S
fmt.Printf("CELL record %s\n\n", m[Cmd])

switch m[Cmd] {
case Delete:
Expand Down
2 changes: 1 addition & 1 deletion bob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestNewFromTape(t *testing.T) {
t.Errorf("Failed to create new magic from tape")
}

if tx["app"] != &myapp {
if tx["app"] != myapp {
t.Errorf("Unexpected output %+v %s", tx, tx["app"])
}
}
3 changes: 1 addition & 2 deletions magic.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ func (m MAP) remove(cells []bpu.Cell) {
func (m MAP) delete(cells []bpu.Cell) {
// Skip prefix (0) and command (1)
m[MapKeyKey] = *cells[2].S
// a MAP command always has 3 cells, that has already been checked, but an invalid delete without the 4th cell
// is possible, which would crash the program
// a MAP command always has at least 3 cells, but 4th cell is possible
if len(cells) > 3 {
m[MapValueKey] = *cells[3].S
}
Expand Down
4 changes: 2 additions & 2 deletions magic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func TestSet(t *testing.T) {
if err != nil {
t.Fatalf("error occurred: %s", err.Error())
}
if m[mapTestKey] != &mapTestValue {
if m[mapTestKey] != mapTestValue {
t.Errorf("SET Failed %s", m[mapTestKey])
}
}
Expand All @@ -174,7 +174,7 @@ func TestRemove(t *testing.T) {
if err != nil {
t.Fatalf("error occurred: %s", err.Error())
}
if m[mapKey] != &keyName1 {
if m[mapKey] != keyName1 {
t.Errorf("REMOVE Failed %s", m[mapKey])
}
}
Expand Down

0 comments on commit 5c13f8b

Please sign in to comment.