1
0
mirror of https://github.com/ariejan/i6502.git synced 2024-11-17 11:04:48 +00:00
i6502/rom_test.go

45 lines
975 B
Go
Raw Normal View History

2014-08-17 14:20:30 +00:00
package i6502
import (
"testing"
"github.com/stretchr/testify/assert"
2014-08-17 14:20:30 +00:00
)
func TestRomAsMemory(t *testing.T) {
assert.Implements(t, (*Memory)(nil), new(Rom))
}
2014-08-17 14:20:30 +00:00
func Test8kRoms(t *testing.T) {
rom, err := NewRom("test/8kb.rom")
assert.Nil(t, err)
assert.EqualValues(t, 0x2000, rom.Size())
assert.EqualValues(t, 0x01, rom.ReadByte(0x0000))
assert.EqualValues(t, 0xFF, rom.ReadByte(0x2000-1))
2014-08-17 14:20:30 +00:00
}
func TestRomWritePanic(t *testing.T) {
rom, _ := NewRom("test/8kb.rom")
// Writing to rom should panic
assert.Panics(t, func() {
rom.WriteByte(0x1337, 0x42)
2014-08-17 14:20:30 +00:00
}, "Writing to Rom should panic")
}
func Test16kRom(t *testing.T) {
rom, err := NewRom("test/16kb.rom")
assert.Nil(t, err)
assert.EqualValues(t, 0x4000, rom.Size())
assert.EqualValues(t, 0x01, rom.ReadByte(0x0000))
assert.EqualValues(t, 0xFF, rom.ReadByte(0x4000-1))
2014-08-17 14:20:30 +00:00
}
func TestRomNotFound(t *testing.T) {
rom, err := NewRom("test/does-not-exists.rom")
assert.NotNil(t, err)
assert.Nil(t, rom)
}