Advertisement
Guest User

Untitled

a guest
Jan 25th, 2015
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. public function diviser($a, $b)
  2. {
  3. if (0 == $b) {
  4. throw new UnexpectedValueException;
  5. }
  6.  
  7. return $a / $b;
  8. }
  9. ------------------------------------------------------------------------
  10. public function testDiviserDiviseurZero()
  11. {
  12. $this->setExpectedException('UnexpectedValueException');
  13. $this->calculateur->diviser(10,0);
  14. }
  15. ------------------------------------------------------------------------
  16. public function testDiviserNormal()
  17. {
  18. $this->assertEquals(2, $this->calculateur->diviser(20, 10));
  19. }
  20. ------------------------------------------------------------------------
  21. public function testDiviserDividendeNegatif()
  22. {
  23. $this->assertEquals(-2, $this->calculateur->diviser(-20, 10));
  24. }
  25. ------------------------------------------------------------------------
  26. public function testDiviserDividendeNegatifAleatoire()
  27. {
  28. $this->assertLessThan(0, $this->calculateur->diviser(mt_rand(-10, -1), 10));
  29. }
  30. ------------------------------------------------------------------------
  31. public function testDiviserDiviseurNegatif()
  32. {
  33. $this->assertEquals(-2, $this->calculateur->diviser(20, -10));
  34. }
  35. ------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement