implement a whole bunch of simple methods.

PredicateUtilitiesTest.java 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. import static org.junit.Assert.*;
  2. import org.junit.After;
  3. import org.junit.Before;
  4. import org.junit.Test;
  5. /**
  6. * The test class PredicateUtilitiesTest.
  7. *
  8. * @author (your name)
  9. * @version (a version number or a date)
  10. */
  11. public class PredicateUtilitiesTest
  12. {
  13. private PredicateUtilities math;
  14. /**
  15. * Sets up the test fixture.
  16. *
  17. * Called before every test case method.
  18. */
  19. @Before
  20. public void setUp()
  21. {
  22. math = new PredicateUtilities();
  23. }
  24. @Test
  25. public void testGreaterThanTrue() {
  26. // : Given
  27. int greaterValue = 450;
  28. int lesserValue = 350;
  29. // : When
  30. boolean outcome = math.isGreaterThan(greaterValue, lesserValue);
  31. // : Then
  32. assertTrue(outcome);
  33. }
  34. @Test
  35. public void testGreaterThanFalse() {
  36. // : Given
  37. int greaterValue = 350;
  38. int lesserValue = 350;
  39. // : When
  40. boolean outcome = math.isGreaterThan(greaterValue, lesserValue);
  41. // : Then
  42. assertFalse(outcome);
  43. }
  44. @Test
  45. public void testLessThanTrue() {
  46. // : Given
  47. int greaterValue = 450;
  48. int lesserValue = 350;
  49. // : When
  50. boolean outcome = math.isLessThan(greaterValue, lesserValue);
  51. // : Then
  52. assertFalse(outcome);
  53. }
  54. @Test
  55. public void testLessThan1() {
  56. // : Given
  57. int greaterValue = 450;
  58. int lesserValue = 350;
  59. // : When
  60. boolean outcome = math.isLessThan(greaterValue, lesserValue);
  61. // : Then
  62. assertFalse(outcome);
  63. }
  64. @Test
  65. public void testLessOrEqual1() {
  66. // : Given
  67. int greaterValue = 3;
  68. int lesserValue = 3;
  69. // : When
  70. boolean outcome = math.isLessThanOrEqualTo(greaterValue, lesserValue);
  71. // : Then
  72. assertTrue(outcome);
  73. }
  74. @Test
  75. public void testLessOrEqual2() {
  76. // : Given
  77. int greaterValue = 3;
  78. int lesserValue = 6;
  79. // : When
  80. boolean outcome = math.isLessThanOrEqualTo(greaterValue, lesserValue);
  81. // : Then
  82. assertTrue(outcome);
  83. }
  84. @Test
  85. public void testGreaterOrEqual1() {
  86. // : Given
  87. int greaterValue = 4;
  88. int lesserValue = 4;
  89. // : When
  90. boolean outcome = math.isGreaterThanOrEqualTo(greaterValue, lesserValue);
  91. // : ThenP
  92. assertTrue(outcome);
  93. }
  94. @Test
  95. public void testGreaterOrEqual2() {
  96. // : Given
  97. int greaterValue = 8;
  98. int lesserValue = 15;
  99. // : When
  100. boolean outcome = math.isGreaterThanOrEqualTo(greaterValue, lesserValue);
  101. // : Then
  102. assertFalse(outcome);
  103. }
  104. }