[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 10/19] qlit: Support all types of QNums
From: |
Eduardo Habkost |
Subject: |
Re: [PATCH v3 10/19] qlit: Support all types of QNums |
Date: |
Tue, 24 Nov 2020 10:03:06 -0500 |
On Tue, Nov 24, 2020 at 01:22:02PM +0100, Markus Armbruster wrote:
> Paolo Bonzini <pbonzini@redhat.com> writes:
>
> > On 24/11/20 10:55, Markus Armbruster wrote:
> >>> + /* Larger than UINT64_MAX: */
> >>> + QLIT_QNUM_DOUBLE(18446744073709552e3),
> >>> + /* Smaller than INT64_MIN: */
> >>> + QLIT_QNUM_DOUBLE(-92233720368547758e2),
> >> Why "larger than UINT64_MAX" and "smaller than INT64_MIN"?
> >>
> >
> > I guess the point is to test values that are only representable as a
> > double, so (double)((uint64_t)INT64_MAX+1) wouldn't be very useful for
> > that: as the expression shows, it would not be a QNUM_VAL_INT but it
> > would be representable as QNUM_VAL_UINT.
> >
> > So these are the cases that matter the most, even though -1, 0 and
> > INT64_MAX+1 could be nice to have.
>
> qnum_is_equal()'s contract:
>
> * Doubles are never considered equal to integers.
If that's part of the contract, it would be OK to include
0.0, -1.0, 1.0, INT64_MAX+1 in the list. I incorrectly assumed
qnum_is_equal(qnum_from_int(0), qnum_from_double(0.0))
was undefined.
However, if we really care about test coverage of
qnum_is_equal(), we probably should be extending check-qnum.c,
not check-qlit.c.
--
Eduardo
- [PATCH v3 02/19] qnum: Make num_x/num_y variables at qnum_is_equal() const, (continued)
- [PATCH v3 02/19] qnum: Make num_x/num_y variables at qnum_is_equal() const, Eduardo Habkost, 2020/11/23
- [PATCH v3 04/19] qnum: qnum_value_is_equal() function, Eduardo Habkost, 2020/11/23
- [PATCH v3 07/19] qlit: Use QNumValue to represent QNums, Eduardo Habkost, 2020/11/23
- [PATCH v3 05/19] qlit: Use qnum_value_is_equal() when comparing QNums, Eduardo Habkost, 2020/11/23
- [PATCH v3 03/19] qnum: QNumValue type for QNum value literals, Eduardo Habkost, 2020/11/23
- [PATCH v3 06/19] qlit: Rename QLIT_QNUM to QLIT_QNUM_INT, Eduardo Habkost, 2020/11/23
- [PATCH v3 10/19] qlit: Support all types of QNums, Eduardo Habkost, 2020/11/23
[PATCH v3 09/19] qlit: Add more test literals to qlit_equal_qobject() test case, Eduardo Habkost, 2020/11/23
[PATCH v3 08/19] qlit: Move qlit_equal_qobject() reference values to array, Eduardo Habkost, 2020/11/23
[PATCH v3 11/19] qom: field_prop_set_default_value() helper, Eduardo Habkost, 2020/11/23
[PATCH v3 12/19] qom: Replace defval value in Property with QLitObject, Eduardo Habkost, 2020/11/23
[PATCH v3 13/19] qom: Fix documentation of UUID property type, Eduardo Habkost, 2020/11/23