value: fix union of int range and int when extending on a side
authorVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Mon, 13 Mar 2017 11:08:01 +0000 (11:08 +0000)
committerVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Mon, 20 Mar 2017 14:09:55 +0000 (14:09 +0000)
The internal representation uses bounds scaled by the step

Add tests to catch those cases

gst/gstvalue.c
tests/check/gst/gstvalue.c

index f0dbae2..37f10dd 100644 (file)
@@ -4150,9 +4150,8 @@ gst_value_union_int_int_range (GValue * dest, const GValue * src1,
   /* check if it extends the range */
   if (v == (INT_RANGE_MIN (src2) - 1) * INT_RANGE_STEP (src2)) {
     if (dest) {
-      guint64 new_min =
-          (guint) ((INT_RANGE_MIN (src2) - 1) * INT_RANGE_STEP (src2));
-      guint64 new_max = (guint) (INT_RANGE_MAX (src2) * INT_RANGE_STEP (src2));
+      guint64 new_min = INT_RANGE_MIN (src2) - 1;
+      guint64 new_max = INT_RANGE_MAX (src2);
 
       gst_value_init_and_copy (dest, src2);
       dest->data[0].v_uint64 = (new_min << 32) | (new_max);
@@ -4161,9 +4160,8 @@ gst_value_union_int_int_range (GValue * dest, const GValue * src1,
   }
   if (v == (INT_RANGE_MAX (src2) + 1) * INT_RANGE_STEP (src2)) {
     if (dest) {
-      guint64 new_min = (guint) (INT_RANGE_MIN (src2) * INT_RANGE_STEP (src2));
-      guint64 new_max =
-          (guint) ((INT_RANGE_MAX (src2) + 1) * INT_RANGE_STEP (src2));
+      guint64 new_min = INT_RANGE_MIN (src2);
+      guint64 new_max = INT_RANGE_MAX (src2) + 1;
 
       gst_value_init_and_copy (dest, src2);
       dest->data[0].v_uint64 = (new_min << 32) | (new_max);
index b1b3e22..644d244 100644 (file)
@@ -3081,7 +3081,14 @@ GST_START_TEST (test_stepped_int_range_ops)
     "[16, 32, 16]", "union", "[48, 96, 16]", "[16, 96, 16]"}, {
     "[112, 192, 16]", "union", "[48, 96, 16]", "[48, 192, 16]"}, {
     "[16, 32, 16]", "union", "[64, 96, 16]", NULL}, {
-  "[112, 192, 16]", "union", "[48, 96, 8]", NULL},};
+    "[112, 192, 16]", "union", "[48, 96, 8]", NULL}, {
+    "[10, 20, 5]", "union", "10", "[10, 20, 5]"}, {
+    "[10, 20, 5]", "union", "20", "[10, 20, 5]"}, {
+    "[10, 20, 5]", "union", "15", "[10, 20, 5]"}, {
+    "[10, 20, 5]", "union", "5", "[5, 20, 5]"}, {
+    "[10, 20, 5]", "union", "12", NULL}, {
+    "[10, 20, 5]", "union", "30", NULL}, {
+  "[10, 20, 5]", "union", "25", "[10, 25, 5]"},};
 
   for (n = 0; n < G_N_ELEMENTS (ranges); ++n) {
     gchar *end = NULL;