IntervalTest.php 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 PHPUnit\Framework\TestCase;
  12. use Symfony\Component\Translation\Interval;
  13. class IntervalTest extends TestCase
  14. {
  15. /**
  16. * @dataProvider getTests
  17. */
  18. public function testTest($expected, $number, $interval)
  19. {
  20. $this->assertEquals($expected, Interval::test($number, $interval));
  21. }
  22. /**
  23. * @expectedException \Symfony\Component\Translation\Exception\InvalidArgumentException
  24. */
  25. public function testTestException()
  26. {
  27. Interval::test(1, 'foobar');
  28. }
  29. public function getTests()
  30. {
  31. return array(
  32. array(true, 3, '{1,2, 3 ,4}'),
  33. array(false, 10, '{1,2, 3 ,4}'),
  34. array(false, 3, '[1,2]'),
  35. array(true, 1, '[1,2]'),
  36. array(true, 2, '[1,2]'),
  37. array(false, 1, ']1,2['),
  38. array(false, 2, ']1,2['),
  39. array(true, log(0), '[-Inf,2['),
  40. array(true, -log(0), '[-2,+Inf]'),
  41. );
  42. }
  43. }