tests/check/gst/gstvalue.c: Add unit test for deserializing uint64s and check some...
authorSebastian Dröge <slomo@circular-chaos.org>
Mon, 5 May 2008 15:50:36 +0000 (15:50 +0000)
committerSebastian Dröge <slomo@circular-chaos.org>
Mon, 5 May 2008 15:50:36 +0000 (15:50 +0000)
Original commit message from CVS:
* tests/check/gst/gstvalue.c: (GST_START_TEST), (gst_value_suite):
Add unit test for deserializing uint64s and check some really large
numbers in the int64 test.

ChangeLog
tests/check/gst/gstvalue.c

index 967e30a..201b58b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-05-05  Sebastian Dröge  <slomo@circular-chaos.org>
+
+       * tests/check/gst/gstvalue.c: (GST_START_TEST), (gst_value_suite):
+       Add unit test for deserializing uint64s and check some really large
+       numbers in the int64 test.
+
 2008-05-04  Sebastian Dröge  <slomo@circular-chaos.org>
 
        * tools/gst-inspect.c: (n_print), (print_hierarchy),
index 7bfb6c6..cec60bf 100644 (file)
@@ -99,10 +99,14 @@ GST_START_TEST (test_deserialize_gint64)
   const char *strings[] = {
     "12345678901",
     "-12345678901",
+    "1152921504606846976",
+    "-1152921504606846976",
   };
   gint64 results[] = {
     12345678901LL,
     -12345678901LL,
+    1152921504606846976LL,
+    -1152921504606846976LL,
   };
   int i;
 
@@ -120,6 +124,41 @@ GST_START_TEST (test_deserialize_gint64)
 
 GST_END_TEST;
 
+GST_START_TEST (test_deserialize_guint64)
+{
+  GValue value = { 0 };
+  const char *strings[] = {
+    "0xffffffffffffffff",
+    "9223372036854775810",
+    "-9223372036854775810",
+    "-1",
+    "1",
+    "-0",
+  };
+  guint64 results[] = {
+    0xffffffffffffffffULL,
+    9223372036854775810ULL,
+    9223372036854775806ULL,
+    -1,
+    1,
+    0,
+  };
+  int i;
+
+  g_value_init (&value, G_TYPE_UINT64);
+
+  for (i = 0; i < G_N_ELEMENTS (strings); ++i) {
+    fail_unless (gst_value_deserialize (&value, strings[i]),
+        "could not deserialize %s (%d)", strings[i], i);
+    fail_unless (g_value_get_uint64 (&value) == results[i],
+        "resulting value is %" G_GUINT64_FORMAT ", not %" G_GUINT64_FORMAT
+        ", for string %s (%d)", g_value_get_uint64 (&value),
+        results[i], strings[i], i);
+  }
+}
+
+GST_END_TEST;
+
 GST_START_TEST (test_deserialize_gstfraction)
 {
   GValue value = { 0 };
@@ -1632,6 +1671,7 @@ gst_value_suite (void)
   tcase_add_test (tc_chain, test_deserialize_guint);
   tcase_add_test (tc_chain, test_deserialize_guint_failures);
   tcase_add_test (tc_chain, test_deserialize_gint64);
+  tcase_add_test (tc_chain, test_deserialize_guint64);
   tcase_add_test (tc_chain, test_deserialize_gstfraction);
   tcase_add_test (tc_chain, test_serialize_flags);
   tcase_add_test (tc_chain, test_deserialize_flags);