* [Qemu-devel] [PATCH] Fix and improve qint_from_int64_test
@ 2009-09-08 9:53 Pierre Riteau
2009-09-09 13:41 ` Luiz Capitulino
0 siblings, 1 reply; 2+ messages in thread
From: Pierre Riteau @ 2009-09-08 9:53 UTC (permalink / raw)
To: qemu-devel; +Cc: Pierre Riteau
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>
---
check-qint.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/check-qint.c b/check-qint.c
index ae5d22f..49887bb 100644
--- a/check-qint.c
+++ b/check-qint.c
@@ -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);
}
--
1.6.3.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] Fix and improve qint_from_int64_test
2009-09-08 9:53 [Qemu-devel] [PATCH] Fix and improve qint_from_int64_test Pierre Riteau
@ 2009-09-09 13:41 ` Luiz Capitulino
0 siblings, 0 replies; 2+ messages in thread
From: Luiz Capitulino @ 2009-09-09 13:41 UTC (permalink / raw)
To: Pierre Riteau; +Cc: qemu-devel
On Tue, 8 Sep 2009 11:53:37 +0200
Pierre Riteau <Pierre.Riteau@irisa.fr> wrote:
> 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>
Seems good to me.
Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-09-09 13:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-08 9:53 [Qemu-devel] [PATCH] Fix and improve qint_from_int64_test Pierre Riteau
2009-09-09 13:41 ` Luiz Capitulino
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).