Skip to content

Instantly share code, notes, and snippets.

@technion
Created April 27, 2019 07:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save technion/7c74fad9efd1f14244e25a1cee372a0e to your computer and use it in GitHub Desktop.
Save technion/7c74fad9efd1f14244e25a1cee372a0e to your computer and use it in GitHub Desktop.
Assertion testing
$ 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