MCPcopy Create free account
hub / github.com/djhworld/simple-computer / checkRegister

Function checkRegister

cpu/cpu_test.go:1184–1204  ·  view source on GitHub ↗
(c *CPU, register int, expectedValue uint16, t *testing.T)

Source from the content-addressed store, hash-verified

1182}
1183
1184func checkRegister(c *CPU, register int, expectedValue uint16, t *testing.T) {
1185 var regValue uint16
1186 switch register {
1187 case 0:
1188 regValue = c.gpReg0.Value()
1189 case 1:
1190 regValue = c.gpReg1.Value()
1191 case 2:
1192 regValue = c.gpReg2.Value()
1193 case 3:
1194 regValue = c.gpReg3.Value()
1195 default:
1196 t.Logf("Unknown register %d", register)
1197 t.FailNow()
1198 }
1199
1200 if regValue != expectedValue {
1201 t.Logf("Expected register %d to have value of: %X but got %X", register, expectedValue, regValue)
1202 t.FailNow()
1203 }
1204}
1205
1206func checkRegisters(c *CPU, expReg0, expReg1, expReg2, expReg3 uint16, t *testing.T) {
1207 checkRegister(c, 0, expReg0, t)

Callers 3

testSubtractFunction · 0.85
testMultiplyFunction · 0.85
checkRegistersFunction · 0.85

Calls 1

ValueMethod · 0.80

Tested by

no test coverage detected