tests: Add test for greatest common divisor
authorDavid Schleef <ds@schleef.org>
Wed, 13 Apr 2011 17:24:33 +0000 (10:24 -0700)
committerDavid Schleef <ds@schleef.org>
Wed, 13 Apr 2011 17:31:03 +0000 (10:31 -0700)
tests/check/gst/gstutils.c

index 22c3091..5324b14 100644 (file)
@@ -1031,6 +1031,28 @@ GST_START_TEST (test_pad_proxy_getcaps_aggregation)
 
 GST_END_TEST;
 
+GST_START_TEST (test_greatest_common_divisor)
+{
+  fail_if (gst_util_greatest_common_divisor (1, 1) != 1);
+  fail_if (gst_util_greatest_common_divisor (2, 3) != 1);
+  fail_if (gst_util_greatest_common_divisor (3, 5) != 1);
+  fail_if (gst_util_greatest_common_divisor (-1, 1) != 1);
+  fail_if (gst_util_greatest_common_divisor (-2, 3) != 1);
+  fail_if (gst_util_greatest_common_divisor (-3, 5) != 1);
+  fail_if (gst_util_greatest_common_divisor (-1, -1) != 1);
+  fail_if (gst_util_greatest_common_divisor (-2, -3) != 1);
+  fail_if (gst_util_greatest_common_divisor (-3, -5) != 1);
+  fail_if (gst_util_greatest_common_divisor (1, -1) != 1);
+  fail_if (gst_util_greatest_common_divisor (2, -3) != 1);
+  fail_if (gst_util_greatest_common_divisor (3, -5) != 1);
+  fail_if (gst_util_greatest_common_divisor (2, 2) != 2);
+  fail_if (gst_util_greatest_common_divisor (2, 4) != 2);
+  fail_if (gst_util_greatest_common_divisor (1001, 11) != 11);
+
+}
+
+GST_END_TEST;
+
 static Suite *
 gst_utils_suite (void)
 {
@@ -1063,6 +1085,7 @@ gst_utils_suite (void)
   tcase_add_test (tc_chain, test_binary_search);
 
   tcase_add_test (tc_chain, test_pad_proxy_getcaps_aggregation);
+  tcase_add_test (tc_chain, test_greatest_common_divisor);
   return s;
 }