2014-08-17 14:20:30 +00:00
|
|
|
package i6502
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2014-08-21 08:02:38 +00:00
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2014-08-17 14:20:30 +00:00
|
|
|
)
|
|
|
|
|
2014-08-21 08:02:38 +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)
|
2015-04-09 07:20:02 +00:00
|
|
|
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() {
|
2014-08-21 08:02:38 +00:00
|
|
|
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)
|
2015-04-09 07:20:02 +00:00
|
|
|
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)
|
|
|
|
}
|