Skip to content

Instantly share code, notes, and snippets.

@KristianLyng
Created March 14, 2013 13:54
Show Gist options
  • Select an option

  • Save KristianLyng/5161491 to your computer and use it in GitHub Desktop.

Select an option

Save KristianLyng/5161491 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#define test(n, op) do { \
int value; \
printf("Take %d (%s, x: %d, y: %d)\n", n, #op, x,y); \
printf(#op ": %s ", (value = op) ? "TRUE" : "FALSE"); \
printf(" X: %d Y: %d\n\n", x, y); \
} while(0)
int main(void) {
int x=10, y=10;
test(1, 5 != 2);
test(2, 5 != 5);
x = 5; y = 2;
test(3, x =! y);
x = 5; y = 5;
test(4, x =! y);
x = 5; y = 2;
test(5, x != y);
x = 5; y = 5;
test(6, x != y);
}
Take 1 (5 != 2, x: 10, y: 10)
5 != 2: TRUE X: 10 Y: 10
Take 2 (5 != 5, x: 10, y: 10)
5 != 5: FALSE X: 10 Y: 10
Take 3 (x =! y, x: 5, y: 2)
x =! y: FALSE X: 0 Y: 2
Take 4 (x =! y, x: 5, y: 5)
x =! y: FALSE X: 0 Y: 5
Take 5 (x != y, x: 5, y: 2)
x != y: TRUE X: 5 Y: 2
Take 6 (x != y, x: 5, y: 5)
x != y: FALSE X: 5 Y: 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment