1 /*
2 * Copyright 2017, ohnx, me@masonx.ca.
3 * Distributed under the terms of the CC0 License.
4 */
5
6 #include <stdint.h>
7 #include <stdlib.h>
8 #include <stdio.h>
9
10 int
main()11 main()
12 {
13 void *ptr;
14
15 printf("Testing calloc(SIZE_MAX, SIZE_MAX)... ");
16 if (calloc(SIZE_MAX, SIZE_MAX) != NULL) {
17 printf("fail!\n");
18 return -1;
19 }
20 printf("pass!\n");
21
22 printf("Testing calloc(0, 0)... ");
23 ptr = calloc(0, 0);
24 /* free the value, since calloc() should return a free() able pointer */
25 free(ptr);
26 /* if the test reaches this point, then calloc() works exactly as expected */
27 printf("pass!\n");
28
29 printf("Testing calloc(-1, -1)... ");
30 if (calloc(-1, -1) != NULL) {
31 printf("fail!\n");
32 return -1;
33 }
34 printf("pass!\n");
35
36 return 0;
37 }
38