First commit
This commit is contained in:
26
tests/AVRTest.php
Normal file
26
tests/AVRTest.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SimAVRPHP\Tests;
|
||||
|
||||
use SimAVRPHP\AVR;
|
||||
|
||||
use Psr\Log\NullLogger;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
|
||||
#[CoversClass(AVR::class)]
|
||||
class AVRTest extends TestCase
|
||||
{
|
||||
public function testStepNOP(): void
|
||||
{
|
||||
$avr = new AVR(new NullLogger);
|
||||
$avr->setMemory("\00\00\00\00");
|
||||
$avr->step();
|
||||
}
|
||||
|
||||
|
||||
}
|
40
tests/ProgramCounterTest.php
Normal file
40
tests/ProgramCounterTest.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SimAVRPHP\Tests;
|
||||
|
||||
use SimAVRPHP\ProgramCounter;
|
||||
use SimAVRPHP\Exceptions\InvalidAddressException;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
|
||||
#[CoversClass(ProgramCounter::class)]
|
||||
class ProgramCounterTest extends TestCase
|
||||
{
|
||||
public function testStepAndSet(): void
|
||||
{
|
||||
$pc = new ProgramCounter();
|
||||
$this->assertEquals(0, $pc->get());
|
||||
|
||||
$pc->stepWords(1); //Step 1 word
|
||||
|
||||
$this->assertEquals(2, $pc->get());
|
||||
|
||||
$pc->jump(0x100);
|
||||
$this->assertEquals(0x100, $pc->get());
|
||||
|
||||
$pc->reset();
|
||||
$this->assertEquals(0, $pc->get());
|
||||
}
|
||||
|
||||
public function testSetinvalid(): void
|
||||
{
|
||||
$pc = new ProgramCounter();
|
||||
$this->expectException(InvalidAddressException::class);
|
||||
$pc->jump(3); //Uneven address
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user