Here it is an example:
ApexTest:
@isTest
private class DateExampleTest {
@isTest static void test_method_one() {
//test 7 days diff
Date startDate = Date.today().addDays(0);
Date endDate = Date.today().addDays(7);
Integer diffDays = startDate.daysBetween(endDate);
System.debug(diffDays);
System.assertEquals(7, diffDays);
Integer diffWeeks = diffDays / 7;
System.debug(diffWeeks);
System.assertEquals(1, diffWeeks);
//test 15 days diff
startDate = Date.today().addDays(0);
endDate = Date.today().addDays(15);
diffDays = startDate.daysBetween(endDate);
System.debug(diffDays);
System.assertEquals(15, diffDays);
diffWeeks = diffDays / 7;
System.debug(diffWeeks);
System.assertEquals(2, diffWeeks);
//test 14 days diff back and forward
startDate = Date.today().addDays(-7);
endDate = Date.today().addDays(7);
diffDays = startDate.daysBetween(endDate);
System.debug(diffDays);
System.assertEquals(14, diffDays);
diffWeeks = diffDays / 7;
System.debug(diffWeeks);
System.assertEquals(2, diffWeeks);
}
}