mirror of
https://github.com/macocianradu/goboy.git
synced 2026-03-18 21:10:07 +00:00
added shift function and tests
This commit is contained in:
5
cpu/operations/shift.go
Normal file
5
cpu/operations/shift.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package operations
|
||||
|
||||
func Shift(r1 *byte) {
|
||||
*r1 = *r1 << 1
|
||||
}
|
||||
17
cpu/operations/shift_test.go
Normal file
17
cpu/operations/shift_test.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package operations
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestShift(t *testing.T) {
|
||||
r1 := byte(0b01010101)
|
||||
Shift(&r1)
|
||||
|
||||
expected := byte(0b10101010)
|
||||
actual := r1
|
||||
|
||||
if actual != expected {
|
||||
t.Errorf("actual %x != expected %x", actual, expected)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user