chiark / gitweb /
test-alloc-util: add a "test" for bool casts
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 11 Jun 2018 14:07:45 +0000 (16:07 +0200)
committerSven Eden <yamakuzure@gmx.net>
Fri, 24 Aug 2018 14:47:08 +0000 (16:47 +0200)
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.

src/test/test-alloc-util.c

index fa3bb9f440b5f2425189da1621aeb6f095ef51a8..324f786c37149af129dfa083b381faa02ffab7d1 100644 (file)
@@ -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;
 }