Last active
October 1, 2015 14:33
-
-
Save alepez/65c5115a0b6f2b444b67 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
static int aStrangeFunction() { | |
return ({ std::string xxx{"the answer is"}; 42; }); | |
} | |
TEST(AStrangeFunction, AlwaysReturnTheAnswer) { | |
ASSERT_EQ(42, aStrangeFunction()); | |
} |
This file contains hidden or 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
#define sys_errmsg(fmt, ...) ({ \ | |
int _err = errno; \ | |
errmsg(fmt, ##__VA_ARGS__); \ | |
fprintf(stderr, "%*serror %d (%s)\n", (int)sizeof(PROGRAM_NAME) + 1,\ | |
"", _err, strerror(_err)); \ | |
-1; \ | |
}) |
This file contains hidden or 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
static int read_positive_ll(const char *file, long long *value) | |
{ | |
// ... | |
if (close(fd)) | |
return sys_errmsg("close failed on \"%s\"", file); | |
return 0; | |
out_error: | |
close(fd); | |
return -1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment