some code samples, various examples of simple modeling ideas and some minor algorithms.

DateTest.java 706B

12345678910111213141516171819202122232425262728293031323334353637383940
  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 DateTest.
  7. *
  8. * @author (your name)
  9. * @version (a version number or a date)
  10. */
  11. public class DateTest
  12. {
  13. Date test;
  14. Date d;
  15. @Test
  16. public void toStringTest() {
  17. try{test = new Date(8,2,1985);}
  18. catch(DateException de){};
  19. String expected = "8/2/1985";
  20. String actual = test.toString();
  21. assertEquals(expected,actual);
  22. }
  23. @Test
  24. public void lessThanTest(){
  25. try{test = new Date(8,2,1985);}
  26. catch(DateException de){};
  27. try{d = new Date(9,2,1985);}
  28. catch(DateException de){};
  29. assertTrue(test.lessThan(d));
  30. }
  31. }