mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-31 11:32:38 +00:00
gstvalue: Fix comparision of double range
Checking twice the lower bound is great (you never know, it might change between the two calls by someone using emacs butterfly-mode), but it's a bit more useful to check the higher bound are also identical. Detected by Coverity
This commit is contained in:
parent
b363ab17e7
commit
3ea6b04c10
2 changed files with 21 additions and 1 deletions
|
@ -1522,7 +1522,7 @@ static gint
|
|||
gst_value_compare_double_range (const GValue * value1, const GValue * value2)
|
||||
{
|
||||
if (value2->data[0].v_double == value1->data[0].v_double &&
|
||||
value2->data[0].v_double == value1->data[0].v_double)
|
||||
value2->data[1].v_double == value1->data[1].v_double)
|
||||
return GST_VALUE_EQUAL;
|
||||
return GST_VALUE_UNORDERED;
|
||||
}
|
||||
|
|
|
@ -1475,6 +1475,26 @@ GST_START_TEST (test_value_subtract_double)
|
|||
/* double_range <-> double_range
|
||||
*/
|
||||
|
||||
/* Check equality */
|
||||
g_value_init (&src1, GST_TYPE_DOUBLE_RANGE);
|
||||
gst_value_set_double_range (&src1, 10.0, 20.0);
|
||||
g_value_init (&src2, GST_TYPE_DOUBLE_RANGE);
|
||||
gst_value_set_double_range (&src2, 10.0, 15.0);
|
||||
/* They are not equal (higher bound is different */
|
||||
fail_if (gst_value_compare (&src1, &src2) == GST_VALUE_EQUAL);
|
||||
g_value_unset (&src1);
|
||||
/* They are not equal (lower bound is different */
|
||||
g_value_init (&src1, GST_TYPE_DOUBLE_RANGE);
|
||||
gst_value_set_double_range (&src1, 5.0, 15.0);
|
||||
fail_if (gst_value_compare (&src1, &src2) == GST_VALUE_EQUAL);
|
||||
g_value_unset (&src1);
|
||||
/* And finally check equality */
|
||||
g_value_init (&src1, GST_TYPE_DOUBLE_RANGE);
|
||||
gst_value_set_double_range (&src1, 10.0, 15.0);
|
||||
fail_unless (gst_value_compare (&src1, &src2) == GST_VALUE_EQUAL);
|
||||
g_value_unset (&src1);
|
||||
g_value_unset (&src2);
|
||||
|
||||
/* same range, empty set */
|
||||
g_value_init (&src1, GST_TYPE_DOUBLE_RANGE);
|
||||
gst_value_set_double_range (&src1, 10.0, 20.0);
|
||||
|
|
Loading…
Reference in a new issue