summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-06-13 10:34:30 +0200
committerSven Eden <yamakuzure@gmx.net>2018-08-24 16:47:08 +0200
commit1816567a45928b1022db20bdc00db66b9717a83f (patch)
tree45e623bea80d520848074cb467b302699e5793ee /src/test
parentd9537fde9944a03f48054e0f4b6a9aea7d3c2a9d (diff)
test-alloc-util: add casts to bools from p ointers
C++03: "An rvalue of arithmetic, enumeration, pointer, or pointer to member type can be converted to an rvalue of type bool. A zero value, null pointer value, or null member pointer value is converted to false; any other value is converted to true" C should behave the same because pointers are scalars in C, but let's verify that.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test-alloc-util.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/test/test-alloc-util.c b/src/test/test-alloc-util.c
index 324f786c3..88670ae9e 100644
--- a/src/test/test-alloc-util.c
+++ b/src/test/test-alloc-util.c
@@ -58,19 +58,23 @@ static void test_memdup_multiply_and_greedy_realloc(void) {
}
static void test_bool_assign(void) {
- bool b, c, *cp = &c, d, e, f;
+ bool b, c, *cp = &c, d, e, f, g, h;
b = 123;
*cp = -11;
d = 0xF & 0xFF;
e = b & d;
f = 0x0;
+ g = cp; /* cast from pointer */
+ h = NULL; /* cast from pointer */
assert(b);
assert(c);
assert(d);
assert(e);
assert(!f);
+ assert(g);
+ assert(!h);
}
int main(int argc, char *argv[]) {