Skip to content

Commit

Permalink
Fix and improve qint_from_int64_test
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
priteau authored and aurel32 committed Sep 26, 2009
1 parent e0fed6c commit 02c068c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions check-qint.c
Expand Up @@ -43,10 +43,10 @@ END_TEST
START_TEST(qint_from_int64_test) START_TEST(qint_from_int64_test)
{ {
QInt *qi; QInt *qi;
const int64_t value = 0xffffffffffffffff; const int64_t value = 0x1234567890abcdefLL;


qi = qint_from_int(value); qi = qint_from_int(value);
fail_unless(qi->value == value); fail_unless((int64_t) qi->value == value);


QDECREF(qi); QDECREF(qi);
} }
Expand Down

0 comments on commit 02c068c

Please sign in to comment.