Created
April 27, 2019 07:36
-
-
Save technion/7c74fad9efd1f14244e25a1cee372a0e to your computer and use it in GitHub Desktop.
Assertion testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat assertion.c | |
#include <stdio.h> | |
#include <assert.h> | |
int main() | |
{ | |
int i = 7; | |
assert(i > 10); | |
printf("Just printing something\n"); | |
return 0; | |
} | |
// Expected test case | |
$ clang -Wall -Wextra assertion.c -o assertion | |
$ ./assertion | |
assertion: assertion.c:7: int main(): Assertion `i > 10' failed. | |
Aborted (core dumped) | |
// Main test case | |
$ clang -Wall -Wextra assertion.c -O3 -o assertion | |
$ ./assertion | |
assertion: assertion.c:7: int main(): Assertion `i > 10' failed. | |
Aborted (core dumped) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment