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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 CalendarTest.
  7. *
  8. * @author (your name)
  9. * @version (a version number or a date)
  10. */
  11. public class CalendarTest
  12. {
  13. Calendar test;
  14. @Test
  15. public void addDayTest() {
  16. try{test = new Calendar(8,2,1985);}
  17. catch(DateException de){};
  18. test.addDay();
  19. assertTrue(test.day == 9);
  20. }
  21. @Test
  22. public void subDayTest() {
  23. try{test = new Calendar(8,2,1985);}
  24. catch(DateException de){};
  25. test.subDay();
  26. assertTrue(test.day == 7);
  27. }
  28. @Test
  29. public void addMonthTest() {
  30. try{test = new Calendar(8,2,1985);}
  31. catch(DateException de){};
  32. test.addMonth();
  33. assertTrue(test.month == 3);
  34. }
  35. @Test
  36. public void subMonthTest() {
  37. try{test = new Calendar(8,2,1985);}
  38. catch(DateException de){};
  39. test.subMonth();
  40. assertTrue(test.month == 1);
  41. }
  42. @Test
  43. public void addyearTest() {
  44. try{test = new Calendar(8,2,1985);}
  45. catch(DateException de){};
  46. test.addYear();
  47. assertTrue(test.year == 1986);
  48. }
  49. @Test
  50. public void subyearTest() {
  51. try{test = new Calendar(8,2,1985);}
  52. catch(DateException de){};
  53. test.subYear();
  54. assertTrue(test.year == 1984);
  55. }
  56. }