MCPcopy Create free account
hub / github.com/GCMiner/GCMiner / CalendarTest

Class CalendarTest

src/test/java/examples/CalendarTest.java:13–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11import edu.berkeley.cs.jqf.fuzz.*;
12
13@RunWith(JQF.class)
14public class CalendarTest {
15
16 @Fuzz
17 public void testLeapYear(@From(CalendarGenerator.class) GregorianCalendar cal) {
18 // Assume that the date is Feb 29
19 assumeTrue(cal.get(MONTH) == FEBRUARY);
20 assumeTrue(cal.get(DAY_OF_MONTH) == 29);
21
22 // Under this assumption, validate leap year rules
23 assertTrue(cal.get(YEAR) + " should be a leap year", CalendarLogic.isLeapYear(cal));
24 }
25
26 @Fuzz
27 public void testCompare(@Size(max=100) List<@From(CalendarGenerator.class) GregorianCalendar> cals) {
28 // Sort list of calendar objects using our custom comparator function
29 Collections.sort(cals, CalendarLogic::compare);
30
31 // If they have an ordering, then the sort should succeed
32 for (int i = 1; i < cals.size(); i++) {
33 Calendar c1 = cals.get(i-1);
34 Calendar c2 = cals.get(i);
35 assumeFalse(c1.equals(c2)); // Assume that we have distinct dates
36 assertTrue(c1 + " should be before " + c2, c1.before(c2)); // Then c1 < c2
37 }
38 }
39}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected