Skip to content

Commit

Permalink
Added tests for negative values
Browse files Browse the repository at this point in the history
  • Loading branch information
marius-meissner committed Jan 11, 2018
1 parent a0dd317 commit 19b7c9b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/BitBangingInterfaceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,17 @@ public function test_transfer_tooBig()
$this->interface->transfer([1024]);
}

/**
* @expectedException \Volantus\BerrySpi\InvalidArgumentException
* @expectedExceptionMessage Invalid data given => no negative values allowed
*/
public function test_transfer_negative()
{
$this->interface = new BitBangingInterface(12, 16, 20, 21, 512, 0);
$this->interface->open();
$this->interface->transfer([-1]);
}

/**
* For this test GPIO16 (MISO) and GPIO20 (MOSI) pins needs to be connected (e.g. jumper cable)
*/
Expand Down
22 changes: 22 additions & 0 deletions tests/RegularInterfaceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,17 @@ public function test_transfer_tooBig()
$this->interface->transfer([1024]);
}

/**
* @expectedException \Volantus\BerrySpi\InvalidArgumentException
* @expectedExceptionMessage Invalid data given => no negative values allowed
*/
public function test_transfer_negative()
{
$this->interface = new RegularInterface(1, 32000, 0);
$this->interface->open();
$this->interface->transfer([-1]);
}

/**
* For this test SPI_MISO (GPIO09) and SPI_MOSI (GPIO10) pins needs to be connected (e.g. jumper cable)
*/
Expand Down Expand Up @@ -209,6 +220,17 @@ public function test_write_tooBig()
$this->interface->write([1024]);
}

/**
* @expectedException \Volantus\BerrySpi\InvalidArgumentException
* @expectedExceptionMessage Invalid data given => no negative values allowed
*/
public function test_write_negative()
{
$this->interface = new RegularInterface(1, 32000, 0);
$this->interface->open();
$this->interface->write([-1]);
}

public function test_getChannel_correct()
{
$interface = new RegularInterface(2, 32000, 0);
Expand Down

0 comments on commit 19b7c9b

Please sign in to comment.