OrderingComparisonTest.php 1000B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace Hamcrest\Number;
  3. class OrderingComparisonTest extends \Hamcrest\AbstractMatcherTest
  4. {
  5. protected function createMatcher()
  6. {
  7. return \Hamcrest\Number\OrderingComparison::greaterThan(1);
  8. }
  9. public function testComparesValuesForGreaterThan()
  10. {
  11. assertThat(2, greaterThan(1));
  12. assertThat(0, not(greaterThan(1)));
  13. }
  14. public function testComparesValuesForLessThan()
  15. {
  16. assertThat(2, lessThan(3));
  17. assertThat(0, lessThan(1));
  18. }
  19. public function testComparesValuesForEquality()
  20. {
  21. assertThat(3, comparesEqualTo(3));
  22. assertThat('aa', comparesEqualTo('aa'));
  23. }
  24. public function testAllowsForInclusiveComparisons()
  25. {
  26. assertThat(1, lessThanOrEqualTo(1));
  27. assertThat(1, greaterThanOrEqualTo(1));
  28. }
  29. public function testSupportsDifferentTypesOfComparableValues()
  30. {
  31. assertThat(1.1, greaterThan(1.0));
  32. assertThat("cc", greaterThan("bb"));
  33. }
  34. }