i6502/ram_test.go

29 lines
542 B
Go
Raw Permalink Normal View History

2014-08-13 07:26:33 +00:00
package i6502
import (
"testing"
"github.com/stretchr/testify/assert"
2014-08-13 07:26:33 +00:00
)
func TestRamAsMemory(t *testing.T) {
assert.Implements(t, (*Memory)(nil), new(Ram))
}
2014-08-13 07:26:33 +00:00
func TestRamSize(t *testing.T) {
ram, _ := NewRam(0x8000) // 32 kB
assert.EqualValues(t, 0x8000, ram.Size())
2014-08-13 07:26:33 +00:00
}
func TestRamReadWrite(t *testing.T) {
ram, _ := NewRam(0x8000) // 32 kB
// Ram zeroed out initially
for i := 0; i < 0x8000; i++ {
assert.EqualValues(t, 0x00, ram.data[i])
2014-08-13 07:26:33 +00:00
}
ram.WriteByte(0x1000, 0x42)
assert.EqualValues(t, 0x42, ram.ReadByte(0x1000))
2014-08-13 07:26:33 +00:00
}