@Test public void testReadByte() { byte[] ramData = new byte[] {0, 1, (byte) 0377, (byte) 0376}; RandomAccessMemory ram = new RandomAccessMemory("TestRam", 01000, ramData); assertEquals(0, ram.read(true, 01000)); assertEquals(1, ram.read(true, 01001)); assertEquals(0377, ram.read(true, 01002)); assertEquals(0376, ram.read(true, 01003)); }
@Test public void testWriteByte() { byte[] ramData = new byte[] {0, 0}; RandomAccessMemory ram = new RandomAccessMemory("TestRam", 01000, ramData); ram.write(true, 01000, 1); assertEquals(1, ram.read(false, 01000)); ram.write(true, 01001, 0377); assertEquals((0377 << 8) + 1, ram.read(false, 01000)); ram.write(true, 01001, 0177777); assertEquals((0377 << 8) + 1, ram.read(false, 01000)); }
@Test public void testReadWord() { short[] ramData = new short[] {0, 1, (short) 0177777, (short) 0177776}; RandomAccessMemory ram = new RandomAccessMemory("TestRam", 01000, ramData); assertEquals(0, ram.read(false, 01000)); assertEquals(0, ram.read(false, 01001)); assertEquals(1, ram.read(false, 01002)); assertEquals(1, ram.read(false, 01003)); assertEquals(0177777, ram.read(false, 01004)); assertEquals(0177777, ram.read(false, 01005)); assertEquals(0177776, ram.read(false, 01006)); assertEquals(0177776, ram.read(false, 01007)); }
@Test public void testWriteWord() { short[] ramData = new short[] {0, 0}; RandomAccessMemory ram = new RandomAccessMemory("TestRam", 01000, ramData); ram.write(false, 01000, 0377); assertEquals(0377, ram.read(false, 01000)); ram.write(false, 01001, 0377); assertEquals(0377, ram.read(false, 01000)); ram.write(false, 01002, 0177777); assertEquals(0177777, ram.read(false, 01002)); ram.write(false, 01003, 0177777); assertEquals(0177777, ram.read(false, 01002)); ram.write(false, 01002, 01777777); assertEquals(0177777, ram.read(false, 01002)); }