diff --git a/test/emu/cpu_test.cc b/test/emu/cpu_test.cc index 7d9790f9..6bb141e7 100644 --- a/test/emu/cpu_test.cc +++ b/test/emu/cpu_test.cc @@ -91,13 +91,10 @@ TEST_F(CPUTest, ADC_DirectPageIndexedIndirectX) { TEST_F(CPUTest, ADC_StackRelative) { cpu.A = 0x03; - cpu.SetSP(0x01FF); // Setting Stack Pointer to 0x01FF std::vector data = {0x63, 0x02}; // ADC sr mock_memory.SetMemoryContents(data); mock_memory.InsertMemory(0x0201, {0x06}); // [0x0201] = 0x06 - EXPECT_CALL(mock_memory, SP()).WillOnce(Return(0x01FF)); - EXPECT_CALL(mock_memory, ReadByte(0x0001)).WillOnce(Return(0x02)); // Operand EXPECT_CALL(mock_memory, ReadByte(0x0201)) .WillOnce(Return(0x06)); // Memory value @@ -222,16 +219,14 @@ TEST_F(CPUTest, ADC_DirectPageIndirect) { } TEST_F(CPUTest, ADC_StackRelativeIndirectIndexedY) { - cpu.A = 0x03; // A register - cpu.Y = 0x02; // Y register - cpu.DB = 0x10; // Setting Data Bank register to 0x20 - cpu.SetSP(0x01FF); // Setting Stack Pointer to 0x01FF + cpu.A = 0x03; // A register + cpu.Y = 0x02; // Y register + cpu.DB = 0x10; // Setting Data Bank register to 0x20 std::vector data = {0x73, 0x02}; // ADC sr, Y mock_memory.SetMemoryContents(data); mock_memory.InsertMemory(0x0201, {0x00, 0x30}); // [0x0201] = 0x3000 mock_memory.InsertMemory(0x103002, {0x06}); // [0x3002] = 0x06 - EXPECT_CALL(mock_memory, SP()).WillOnce(Return(0x01FF)); EXPECT_CALL(mock_memory, ReadByte(0x0001)).WillOnce(Return(0x02)); EXPECT_CALL(mock_memory, ReadWord(0x0201)).WillOnce(Return(0x3000)); EXPECT_CALL(mock_memory, ReadByte(0x103002)).WillOnce(Return(0x06)); @@ -352,14 +347,10 @@ TEST_F(CPUTest, AND_DirectPageIndexedIndirectX) { TEST_F(CPUTest, AND_StackRelative) { cpu.A = 0b11110000; // A register cpu.status = 0xFF; // 8-bit mode - cpu.SetSP(0x01FF); // Setting Stack Pointer to 0x01FF std::vector data = {0x23, 0x02}; mock_memory.SetMemoryContents(data); mock_memory.InsertMemory(0x0201, {0b10101010}); // [0x0201] = 0b10101010 - // Get the operand - EXPECT_CALL(mock_memory, SP()).WillOnce(Return(0x01FF)); - EXPECT_CALL(mock_memory, ReadByte(0x0001)).WillOnce(Return(0x02)); // Get the value at the operand @@ -496,7 +487,7 @@ TEST_F(CPUTest, AND_StackRelativeIndirectIndexedY) { mock_memory.InsertMemory(0x0201, {0x00, 0x30}); // [0x0201] = 0x3000 mock_memory.InsertMemory(0x103002, {0b10101010}); // [0x3002] = 0b10101010 - EXPECT_CALL(mock_memory, SP()).WillOnce(Return(0x01FF)); + EXPECT_CALL(mock_memory, SP()).WillRepeatedly(Return(0x01FF)); EXPECT_CALL(mock_memory, ReadByte(0x0001)).WillOnce(Return(0x02)); EXPECT_CALL(mock_memory, ReadWord(0x0201)).WillOnce(Return(0x3000)); EXPECT_CALL(mock_memory, ReadByte(0x103002)).WillOnce(Return(0b10101010)); @@ -1234,7 +1225,7 @@ TEST_F(CPUTest, CMP_StackRelativeIndirectIndexedY) { mock_memory.InsertMemory(0x0201, {0x00, 0x30}); // [0x0201] = 0x3000 mock_memory.InsertMemory(0x103002, {0x06}); // [0x3002] = 0x06 - EXPECT_CALL(mock_memory, SP()).WillOnce(Return(0x01FF)); + EXPECT_CALL(mock_memory, SP()).WillRepeatedly(Return(0x01FF)); EXPECT_CALL(mock_memory, ReadByte(0x0001)).WillOnce(Return(0x02)); EXPECT_CALL(mock_memory, ReadWord(0x0201)).WillOnce(Return(0x3000)); EXPECT_CALL(mock_memory, ReadByte(0x103002)).WillOnce(Return(0x06)); @@ -3313,7 +3304,7 @@ TEST_F(CPUTest, SBC_StackRelative) { mock_memory.InsertMemory(0x00003E, {0x02}); mock_memory.InsertMemory(0x2002, {0x80}); - EXPECT_CALL(mock_memory, SP()).Times(1); + EXPECT_CALL(mock_memory, SP()).WillRepeatedly(Return(0x01FF)); // EXPECT_CALL(mock_memory, ReadByte(_)).WillOnce(Return(0x3C)); cpu.ExecuteInstruction(0xE3); // SBC Stack Relative @@ -3457,7 +3448,7 @@ TEST_F(CPUTest, SBC_StackRelativeIndirectIndexedY) { mock_memory.InsertMemory(0x0201, {0x00, 0x30}); mock_memory.InsertMemory(0x3002, {0x80}); - EXPECT_CALL(mock_memory, SP()).Times(1); + EXPECT_CALL(mock_memory, SP()).WillRepeatedly(Return(0x01FF)); EXPECT_CALL(mock_memory, ReadByte(0x000001)).WillOnce(Return(0x02)); EXPECT_CALL(mock_memory, ReadWord(0x0201)).WillOnce(Return(0x3000)); EXPECT_CALL(mock_memory, ReadByte(0x3002)).WillOnce(Return(0x80));