summaryrefslogtreecommitdiffstats
path: root/src/test/test-alloc-util.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-06-11 16:07:45 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-06-13 10:52:40 +0200
commit37e744e8661c3edd8b8efa723a3d3c71f73ef542 (patch)
tree13e2175ae8f605c300dbdcce3f18c2af1d2bb968 /src/test/test-alloc-util.c
parentcocinelle: use GNU parallel to run spatch (diff)
downloadsystemd-37e744e8661c3edd8b8efa723a3d3c71f73ef542.tar.xz
systemd-37e744e8661c3edd8b8efa723a3d3c71f73ef542.zip
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.
Diffstat (limited to '')
-rw-r--r--src/test/test-alloc-util.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/test/test-alloc-util.c b/src/test/test-alloc-util.c
index 578c4e2d27..3343e6eecf 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;
}