Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function diviser($a, $b)
- {
- if (0 == $b) {
- throw new UnexpectedValueException;
- }
- return $a / $b;
- }
- ------------------------------------------------------------------------
- public function testDiviserDiviseurZero()
- {
- $this->setExpectedException('UnexpectedValueException');
- $this->calculateur->diviser(10,0);
- }
- ------------------------------------------------------------------------
- public function testDiviserNormal()
- {
- $this->assertEquals(2, $this->calculateur->diviser(20, 10));
- }
- ------------------------------------------------------------------------
- public function testDiviserDividendeNegatif()
- {
- $this->assertEquals(-2, $this->calculateur->diviser(-20, 10));
- }
- ------------------------------------------------------------------------
- public function testDiviserDividendeNegatifAleatoire()
- {
- $this->assertLessThan(0, $this->calculateur->diviser(mt_rand(-10, -1), 10));
- }
- ------------------------------------------------------------------------
- public function testDiviserDiviseurNegatif()
- {
- $this->assertEquals(-2, $this->calculateur->diviser(20, -10));
- }
- ------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement