From: Zbigniew Jędrzejewski-Szmek Date: Mon, 11 Jun 2018 14:07:45 +0000 (+0200) Subject: test-alloc-util: add a "test" for bool casts X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=5794614c99bdb57a405f293923bf17f24dad25e9 test-alloc-util: add a "test" for bool casts Just in case ;) There is no good place, test-alloc-util.c is as good as any, and it's quite short so far, so let's add this there. --- diff --git a/src/test/test-alloc-util.c b/src/test/test-alloc-util.c index fa3bb9f44..324f786c3 100644 --- a/src/test/test-alloc-util.c +++ b/src/test/test-alloc-util.c @@ -57,9 +57,26 @@ static void test_memdup_multiply_and_greedy_realloc(void) { assert_se(p[i] == 0); } +static void test_bool_assign(void) { + bool b, c, *cp = &c, d, e, f; + + b = 123; + *cp = -11; + d = 0xF & 0xFF; + e = b & d; + f = 0x0; + + assert(b); + assert(c); + assert(d); + assert(e); + assert(!f); +} + int main(int argc, char *argv[]) { test_alloca(); test_memdup_multiply_and_greedy_realloc(); + test_bool_assign(); return 0; }