this repo has no description
1#include "dcheck.h"
2
3#include <stdbool.h>
4#include <stdlib.h>
5#include <string.h>
6
7void some_function(void) {
8 // TODO(TaskId): As soon as Brian finishes the hoozywhatsit, write this
9 // function
10 UNIMPLEMENTED("needs Brian's feature");
11}
12
13bool is_even(int val) {
14 switch (val) {
15 case 0:
16 case 2:
17 case 4:
18 return true;
19 case 1:
20 case 3:
21 case 5:
22 return false;
23 }
24 UNREACHABLE("unexpected number %d", val);
25}
26
27// ./a.out ind age month should_call val
28// Try: ./a.out 2 4 8 false 3
29// ...then try making ind bigger than 3
30// ...then try making age bigger than 5
31// ...then try making month bigger than 12 or less than 0
32// ...then try making should_call true
33// ...then try making val bigger than 5
34int main(int argc, char **argv) {
35 CHECK(argc == 6, "Got the wrong number of args (%d)", argc);
36
37 long ind = atol(argv[1]);
38 long age = atol(argv[2]);
39 long month = atol(argv[3]);
40 bool should_call = strcmp(argv[4], "false") == 0 ? false : true;
41 long val = atol(argv[5]);
42
43 int arr[3];
44 // Array index won't crash
45 CHECK_INDEX(ind, 3);
46 (void)arr[ind];
47
48 // Still can order off the kids menu
49 CHECK_BOUND(age, 5);
50
51 // Month is valid
52 CHECK_RANGE(month, 1, 12);
53
54 if (should_call) {
55 some_function();
56 }
57
58 is_even(val);
59}