Add missing // GIVEN, // WHEN, // THEN to unit tests
Summary
Some of the existing unit tests for the 6502 CPU instructionslack the // GIVEN, // WHEN, // THEN structure that improves readability and consistency across the test suite. Adding these comments will make the intent of each test clearer and align them with the project’s test documentation standards.
Steps to Reproduce
- Open the
CPU6502DEYTests file.
- Review the tests:
WillDEYDecrementYCorrectly
WillDEYSetZeroFlag
WillDEYSetNegativeFlag
- Notice that the code lacks explicit
// GIVEN, // WHEN, // THEN sections.
- Observe the inconsistency with other tests that already use this format.
Actual Behavior
The current tests do not have clear section comments describing the setup, action, and verification phases. This can make them harder to follow at a glance.
Expected Behavior
Each test should clearly separate its setup, execution, and verification phases using the // GIVEN, // WHEN, and // THEN comment format.
Example:
TEST_F(CPU6502DEYTests, WillDEYDecrementYCorrectly)
{
// GIVEN: A Y register set to 0x43 and a DEY instruction in memory
cpu.SetRegisterY(0x43);
Memory::Write(0x8000, 0x88); // DEY
// WHEN: The CPU executes one instruction
cpu.Step();
// THEN: The Y register should decrement by one and flags updated correctly
EXPECT_EQ(cpu.GetRegisterY(), 0x42);
EXPECT_FALSE(cpu.GetStatusFlags().Z);
EXPECT_FALSE(cpu.GetStatusFlags().N);
}
Proposed Solution (high level)
Add // GIVEN, // WHEN, and // THEN comments to each test suite that misses it.
Environment
- OS:
n/a
- Other relevant information:
Unit tests, CPU emulation test suite
Acceptance Criteria
Add missing // GIVEN, // WHEN, // THEN to unit tests
Summary
Some of the existing unit tests for the 6502 CPU instructionslack the
// GIVEN,// WHEN,// THENstructure that improves readability and consistency across the test suite. Adding these comments will make the intent of each test clearer and align them with the project’s test documentation standards.Steps to Reproduce
CPU6502DEYTestsfile.WillDEYDecrementYCorrectlyWillDEYSetZeroFlagWillDEYSetNegativeFlag// GIVEN,// WHEN,// THENsections.Actual Behavior
The current tests do not have clear section comments describing the setup, action, and verification phases. This can make them harder to follow at a glance.
Expected Behavior
Each test should clearly separate its setup, execution, and verification phases using the
// GIVEN,// WHEN, and// THENcomment format.Example:
Proposed Solution (high level)
Add
// GIVEN,// WHEN, and// THENcomments to each test suite that misses it.Environment
n/aUnit tests, CPU emulation test suiteAcceptance Criteria
CPU6502 Testscontain// GIVEN,// WHEN,// THENcomments.