説明なし

IntervalTest.php 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Translation\Tests;
  11. use Symfony\Component\Translation\Interval;
  12. class IntervalTest extends \PHPUnit_Framework_TestCase
  13. {
  14. /**
  15. * @dataProvider getTests
  16. */
  17. public function testTest($expected, $number, $interval)
  18. {
  19. $this->assertEquals($expected, Interval::test($number, $interval));
  20. }
  21. /**
  22. * @expectedException \Symfony\Component\Translation\Exception\InvalidArgumentException
  23. */
  24. public function testTestException()
  25. {
  26. Interval::test(1, 'foobar');
  27. }
  28. public function getTests()
  29. {
  30. return array(
  31. array(true, 3, '{1,2, 3 ,4}'),
  32. array(false, 10, '{1,2, 3 ,4}'),
  33. array(false, 3, '[1,2]'),
  34. array(true, 1, '[1,2]'),
  35. array(true, 2, '[1,2]'),
  36. array(false, 1, ']1,2['),
  37. array(false, 2, ']1,2['),
  38. array(true, log(0), '[-Inf,2['),
  39. array(true, -log(0), '[-2,+Inf]'),
  40. );
  41. }
  42. }