1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
|
#include <stdio.h>
#include <stdlib.h>
#include "date.h"
int testDate(Date* date, int d, int m, int y);
int main(void){
Date* d = newDate(29, 2, 2016);
printf("%d\n", isMeaningful(d));
printf("%d\n", testDate(d, 29, 2, 2017));
printf("%d\n", testDate(d, 31, 1, 1990));
printf("%d\n", testDate(d, 31, 6, 1986));
printf("%d\n", testDate(d, 31, 9, 1996));
/* will exit after first failure */
printf("%d\n", testDate(d, 0, 1, 1903));
printf("%d\n", testDate(d, 30, -1, 1905));
printf("%d\n", testDate(d, 20, 1, 1886));
delDate(d);
return EXIT_SUCCESS;
}
int testDate(Date* date, int d, int m, int y){
setDateDay(date, d);
setDateMonth(date, m);
setDateYear(date, y);
return isMeaningful(date);
}
|