]> git.proxmox.com Git - qemu.git/commitdiff
Fix and improve qint_from_int64_test
authorPierre Riteau <Pierre.Riteau@irisa.fr>
Tue, 8 Sep 2009 09:53:37 +0000 (11:53 +0200)
committerAurelien Jarno <aurelien@aurel32.net>
Sat, 26 Sep 2009 19:26:26 +0000 (21:26 +0200)
Use a long long integer constant to fix a compilation error (integer
constant is too large for 'long' type).

Use a better value for testing, as -1 makes the test pass even if
qi->value is of type uint32_t, float or double. This was suggested by
Reimar Döffinger <Reimar.Doeffinger@gmx.de>.

Also, make the test fail when qi->value is of type double or float by
casting qi->value to int64_t, to avoid value being promoted to the type
of qi->value.

Signed-off-by: Pierre Riteau <Pierre.Riteau@irisa.fr>
Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
check-qint.c

index ae5d22f7e7e9fcc373e5caa94762a3dd3a669440..49887bb7d9c1b9514b30fe2a7787758e13b1d8d7 100644 (file)
@@ -43,10 +43,10 @@ END_TEST
 START_TEST(qint_from_int64_test)
 {
     QInt *qi;
-    const int64_t value = 0xffffffffffffffff;
+    const int64_t value = 0x1234567890abcdefLL;
 
     qi = qint_from_int(value);
-    fail_unless(qi->value == value);
+    fail_unless((int64_t) qi->value == value);
 
     QDECREF(qi);
 }