c-template
safe_math_test.c
Go to the documentation of this file.
1
#include <stdio.h>
2
#include <limits.h>
3
#include "../../include/utils/safe_math.h"
4
5
int
main
(
void
) {
6
{
7
bool
passed;
8
safe_sub_uint
(99, 100, &passed);
9
if
(passed) {
10
printf(
"bad check\n"
);
11
}
12
printf(
"success\n"
);
13
}
14
{
15
bool
passed;
16
safe_sub_uint
(100, 99, &passed);
17
if
(!passed) {
18
printf(
"bad check\n"
);
19
}
20
printf(
"success\n"
);
21
}
22
{
23
bool
passed;
24
safe_add_uint
(UINT_MAX, UINT_MAX, &passed);
25
if
(passed) {
26
printf(
"bad check\n"
);
27
}
28
printf(
"success\n"
);
29
}
30
printf(
"%ui\n"
, UINT_MAX + UINT_MAX);
31
}
main
int main(void)
Definition:
safe_math_test.c:5
safe_add_uint
unsigned int safe_add_uint(unsigned int x, unsigned int y, bool *passed)
Definition:
safe_math.c:54
safe_sub_uint
unsigned int safe_sub_uint(unsigned int x, unsigned int y, bool *passed)
Definition:
safe_math.c:44
src
utils
safe_math_test.c
Generated by
1.8.17