Skip to content

Instantly share code, notes, and snippets.

@rhysforyou
Created March 15, 2016 02:25
Show Gist options
  • Select an option

  • Save rhysforyou/71f9cf28c9a181097ca9 to your computer and use it in GitHub Desktop.

Select an option

Save rhysforyou/71f9cf28c9a181097ca9 to your computer and use it in GitHub Desktop.
import XCTest
@testable import GameBro
class CPUTests : XCTestCase {
func testLD() {
var cpu = CPU(memory: Memory())
cpu.LD(&cpu.A, UInt8(20)) // LD A, 20
cpu.LD(&cpu.B, cpu.A) // LD B, A
cpu.LD(&cpu.A, UInt8(10)) // LD A, 10
XCTAssert(cpu.A == UInt8(10), "Accumulator should have value of 10")
XCTAssert(cpu.B == UInt8(20), "B register should have value of 20")
cpu.LD(Address(0xDFFF), cpu.A) // LD $DFFF, A
cpu.LD(&cpu.C, Address(0xDFFF)) // LD C, $DFFF
XCTAssert(cpu.C == UInt8(10), "C register should have value of 10")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment