Browse Source

Finished MMC memory tests.

master
Bryan Miller 5 years ago
parent
commit
b12f868755
1 changed files with 95 additions and 0 deletions
  1. +95
    -0
      test/unit.src.memory.memory.spec.js

+ 95
- 0
test/unit.src.memory.memory.spec.js View File

@@ -349,6 +349,101 @@ describe("Testing Memory Module", function(){
expect(mmc.read(0x0101)).to.equal(0x44);
});

it("Write check", function(){
mmc.write(0x02, 0x06);
expect(mmc.read(0x02)).to.equal(0x06);
mmc.write(0x0115, 0x15);
expect(mmc.read(0x0115)).to.equal(0x15);
mmc.write(0x0207, 0x07);
expect(mmc.read(0x0207)).to.equal(0x07);
});

it("Adding Switchable Banks", function(){
let b2 = new Mem.Memory.ROM(1);
expect(function(){
mmc.connectMemory(b2, 0x0100);
}).to.throw("Memory modules assigned to the same bank must be the same byte size.");
expect(function(){
mmc.connectMemory(b2, 0xEE)
}).to.throw("Cannot align memory module to bank at address " + (0xEE));
mmc.connectMemory(b2, 0x00);
expect(mmc.read(0x00)).to.equal(0x01);
expect(mmc.read(0x01)).to.equal(0x02);
mmc.switchBank(0x01);
expect(mmc.read(0x01)).to.equal(0x00);
mmc.switchBank(0x00);
expect(mmc.read(0x01)).to.equal(0x02);

mmc.connectMemory(new Mem.Memory.ROM(2), 0x0100);
expect(mmc.read(0x0115)).to.equal(0x15);
mmc.switchBank(0x11);
expect(mmc.read(0x0115)).to.equal(0x00);
mmc.switchBank(0x10);
expect(mmc.read(0x0115)).to.equal(0x15);
});

it("Write Check 2 (switch between RAM and ROM)", function(){
mmc.write(0x0115, 0x16);
expect(mmc.read(0x0115)).to.equal(0x16);
mmc.switchBank(0x11);
expect(mmc.read(0x0115)).to.equal(0x00);
mmc.write(0x0115, 0x17);
expect(mmc.read(0x0115)).to.equal(0x00);
mmc.switchBank(0x10);
expect(mmc.read(0x0115)).to.equal(0x16);
});

it("Set Address / Get Byte", function(){
mmc.address = 0x0200;
expect(mmc.byte).to.equal(0x11);
mmc.address = 0x0301;
expect(mmc.byte).to.equal(0xBB);
mmc.address = 0x03;
expect(mmc.byte).to.equal(0x04);
});

it("Set Address / Set Byte", function(){
mmc.address = 0xEE;
mmc.byte = 0x1A;
mmc.address = 0xEF;
mmc.byte = 0x2B;
mmc.address = 0xF0;
mmc.byte = 0x3C;
expect(mmc.read(0xEE)).to.equal(0x1A);
expect(mmc.read(0xEF)).to.equal(0x2B);
expect(mmc.read(0xF0)).to.equal(0x3C);
});

it("Address Within Memory Bounds", function(){
mmc.address = 0x05;
expect(mmc.address).to.equal(0x05);
mmc.address = 0x0201
expect(mmc.address).to.equal(0x0201);
mmc.address = -1;
expect(mmc.address).to.equal(0);
mmc.address = 0x0400;
expect(mmc.address).to.equal(0x03FF);
});

it("Clear Page", function(){
expect(mmc.read(0x0200)).to.equal(0x11);
expect(mmc.read(0x0201)).to.equal(0x22);
mmc.clearPage(2);
expect(mmc.read(0x0200)).to.equal(0x00);
expect(mmc.read(0x0201)).to.equal(0x00);
expect(mmc.read(0xEE)).to.equal(0x1A);
mmc.clearPage(0);
expect(mmc.read(0x00)).to.equal(0x00);
expect(mmc.read(0xEE)).to.equal(0x00);
expect(mmc.read(0xEF)).to.equal(0x00);
});

it("Clear", function(){
mmc.clear();
for (let i=0; i < 10; i++){
expect(mmc.read(0xF6 + i)).to.equal(0x00);
}
});
});
});


Loading…
Cancel
Save