mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-07 07:58:51 +00:00
move over a value_serialize test
Original commit message from CVS: move over a value_serialize test
This commit is contained in:
parent
5d66b9af57
commit
e7ed161f16
13 changed files with 302 additions and 280 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2005-06-21 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||||
|
|
||||||
|
* check/Makefile.am:
|
||||||
|
* check/gst/gstvalue.c: (START_TEST), (gst_value_suite), (main):
|
||||||
|
* testsuite/Makefile.am:
|
||||||
|
* testsuite/caps/Makefile.am:
|
||||||
|
* testsuite/caps/value_serialize.c:
|
||||||
|
* testsuite/test_gst_init.c:
|
||||||
|
move a value_serialize test over
|
||||||
|
|
||||||
2005-06-20 Wim Taymans <wim@fluendo.com>
|
2005-06-20 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
* gst/gstpad.c:
|
* gst/gstpad.c:
|
||||||
|
|
|
@ -23,6 +23,7 @@ clean-local:
|
||||||
done
|
done
|
||||||
|
|
||||||
TESTS = $(top_builddir)/tools/gst-register \
|
TESTS = $(top_builddir)/tools/gst-register \
|
||||||
|
gst/gst \
|
||||||
gst/gstbin \
|
gst/gstbin \
|
||||||
gst/gstbuffer \
|
gst/gstbuffer \
|
||||||
gst/gstbus \
|
gst/gstbus \
|
||||||
|
@ -34,6 +35,7 @@ TESTS = $(top_builddir)/tools/gst-register \
|
||||||
gst/gstpad \
|
gst/gstpad \
|
||||||
gst/gstsystemclock \
|
gst/gstsystemclock \
|
||||||
gst/gsttag \
|
gst/gsttag \
|
||||||
|
gst/gstvalue \
|
||||||
pipelines/simple_launch_lines \
|
pipelines/simple_launch_lines \
|
||||||
pipelines/cleanup \
|
pipelines/cleanup \
|
||||||
gst-libs/gdp
|
gst-libs/gdp
|
||||||
|
|
143
check/gst/gstvalue.c
Normal file
143
check/gst/gstvalue.c
Normal file
|
@ -0,0 +1,143 @@
|
||||||
|
/* GStreamer
|
||||||
|
* Copyright (C) <2004> David Schleef <david at schleef dot org>
|
||||||
|
*
|
||||||
|
* gstvalue.c: Unit tests for GstValue
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "../gstcheck.h"
|
||||||
|
|
||||||
|
|
||||||
|
START_TEST (test_deserialize_buffer)
|
||||||
|
{
|
||||||
|
GValue value = { 0 };
|
||||||
|
|
||||||
|
g_value_init (&value, GST_TYPE_BUFFER);
|
||||||
|
fail_unless (gst_value_deserialize (&value, "1234567890abcdef"));
|
||||||
|
}
|
||||||
|
|
||||||
|
END_TEST;
|
||||||
|
|
||||||
|
START_TEST (test_string)
|
||||||
|
{
|
||||||
|
gchar *try[] = {
|
||||||
|
"Dude",
|
||||||
|
"Hi, I'm a string",
|
||||||
|
"tüüüt!"
|
||||||
|
};
|
||||||
|
gchar *tmp;
|
||||||
|
GValue v = { 0, };
|
||||||
|
guint i;
|
||||||
|
|
||||||
|
g_value_init (&v, G_TYPE_STRING);
|
||||||
|
for (i = 0; i < G_N_ELEMENTS (try); i++) {
|
||||||
|
g_value_set_string (&v, try[i]);
|
||||||
|
tmp = gst_value_serialize (&v);
|
||||||
|
fail_if (tmp == NULL, "couldn't serialize: %s\n", try[i]);
|
||||||
|
fail_unless (gst_value_deserialize (&v, tmp),
|
||||||
|
"couldn't deserialize: %s\n", tmp);
|
||||||
|
g_free (tmp);
|
||||||
|
|
||||||
|
fail_unless (g_str_equal (g_value_get_string (&v), try[i]),
|
||||||
|
"\nserialized : %s\ndeserialized: %s", try[i],
|
||||||
|
g_value_get_string (&v));
|
||||||
|
}
|
||||||
|
g_value_unset (&v);
|
||||||
|
}
|
||||||
|
|
||||||
|
END_TEST;
|
||||||
|
|
||||||
|
START_TEST (test_deserialize_string)
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
gchar *from;
|
||||||
|
gchar *to;
|
||||||
|
} tests[] = {
|
||||||
|
{
|
||||||
|
"", ""}, {
|
||||||
|
"\"\"", ""},
|
||||||
|
/* FAILURES */
|
||||||
|
{
|
||||||
|
"\"", NULL}, /* missing second quote */
|
||||||
|
{
|
||||||
|
"\"Hello\\ World", NULL}, /* missing second quote */
|
||||||
|
{
|
||||||
|
"\"\\", NULL}, /* quote at end, missing second quote */
|
||||||
|
{
|
||||||
|
"\"\\0", NULL}, /* missing second quote */
|
||||||
|
{
|
||||||
|
"\"\\0\"", NULL}, /* unfinished escaped character */
|
||||||
|
{
|
||||||
|
"\" \"", NULL}, /* spaces must be escaped */
|
||||||
|
#if 0
|
||||||
|
/* FIXME 0.9: this test should fail, but it doesn't */
|
||||||
|
{
|
||||||
|
"tüüt", NULL} /* string with special chars must be escaped */
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
guint i;
|
||||||
|
GValue v = { 0, };
|
||||||
|
gboolean ret = TRUE;
|
||||||
|
|
||||||
|
g_value_init (&v, G_TYPE_STRING);
|
||||||
|
for (i = 0; i < G_N_ELEMENTS (tests); i++) {
|
||||||
|
if (gst_value_deserialize (&v, tests[i].from)) {
|
||||||
|
fail_if (tests[i].to == NULL,
|
||||||
|
"I got %s instead of a failure", g_value_get_string (&v));
|
||||||
|
fail_unless (g_str_equal (g_value_get_string (&v), tests[i].to),
|
||||||
|
"\nwanted: %s\ngot : %s", tests[i].to, g_value_get_string (&v));
|
||||||
|
} else {
|
||||||
|
fail_if (tests[i].to != NULL, "failed, but wanted: %s", tests[i].to);
|
||||||
|
ret = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_value_unset (&v);
|
||||||
|
}
|
||||||
|
|
||||||
|
END_TEST;
|
||||||
|
|
||||||
|
Suite *
|
||||||
|
gst_value_suite (void)
|
||||||
|
{
|
||||||
|
Suite *s = suite_create ("GstValue");
|
||||||
|
TCase *tc_chain = tcase_create ("general");
|
||||||
|
|
||||||
|
suite_add_tcase (s, tc_chain);
|
||||||
|
tcase_add_test (tc_chain, test_deserialize_buffer);
|
||||||
|
tcase_add_test (tc_chain, test_string);
|
||||||
|
tcase_add_test (tc_chain, test_deserialize_string);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
int nf;
|
||||||
|
|
||||||
|
Suite *s = gst_value_suite ();
|
||||||
|
SRunner *sr = srunner_create (s);
|
||||||
|
|
||||||
|
gst_check_init (&argc, &argv);
|
||||||
|
|
||||||
|
srunner_run_all (sr, CK_NORMAL);
|
||||||
|
nf = srunner_ntests_failed (sr);
|
||||||
|
srunner_free (sr);
|
||||||
|
|
||||||
|
return nf;
|
||||||
|
}
|
|
@ -23,6 +23,7 @@ clean-local:
|
||||||
done
|
done
|
||||||
|
|
||||||
TESTS = $(top_builddir)/tools/gst-register \
|
TESTS = $(top_builddir)/tools/gst-register \
|
||||||
|
gst/gst \
|
||||||
gst/gstbin \
|
gst/gstbin \
|
||||||
gst/gstbuffer \
|
gst/gstbuffer \
|
||||||
gst/gstbus \
|
gst/gstbus \
|
||||||
|
@ -34,6 +35,7 @@ TESTS = $(top_builddir)/tools/gst-register \
|
||||||
gst/gstpad \
|
gst/gstpad \
|
||||||
gst/gstsystemclock \
|
gst/gstsystemclock \
|
||||||
gst/gsttag \
|
gst/gsttag \
|
||||||
|
gst/gstvalue \
|
||||||
pipelines/simple_launch_lines \
|
pipelines/simple_launch_lines \
|
||||||
pipelines/cleanup \
|
pipelines/cleanup \
|
||||||
gst-libs/gdp
|
gst-libs/gdp
|
||||||
|
|
143
tests/check/gst/gstvalue.c
Normal file
143
tests/check/gst/gstvalue.c
Normal file
|
@ -0,0 +1,143 @@
|
||||||
|
/* GStreamer
|
||||||
|
* Copyright (C) <2004> David Schleef <david at schleef dot org>
|
||||||
|
*
|
||||||
|
* gstvalue.c: Unit tests for GstValue
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "../gstcheck.h"
|
||||||
|
|
||||||
|
|
||||||
|
START_TEST (test_deserialize_buffer)
|
||||||
|
{
|
||||||
|
GValue value = { 0 };
|
||||||
|
|
||||||
|
g_value_init (&value, GST_TYPE_BUFFER);
|
||||||
|
fail_unless (gst_value_deserialize (&value, "1234567890abcdef"));
|
||||||
|
}
|
||||||
|
|
||||||
|
END_TEST;
|
||||||
|
|
||||||
|
START_TEST (test_string)
|
||||||
|
{
|
||||||
|
gchar *try[] = {
|
||||||
|
"Dude",
|
||||||
|
"Hi, I'm a string",
|
||||||
|
"tüüüt!"
|
||||||
|
};
|
||||||
|
gchar *tmp;
|
||||||
|
GValue v = { 0, };
|
||||||
|
guint i;
|
||||||
|
|
||||||
|
g_value_init (&v, G_TYPE_STRING);
|
||||||
|
for (i = 0; i < G_N_ELEMENTS (try); i++) {
|
||||||
|
g_value_set_string (&v, try[i]);
|
||||||
|
tmp = gst_value_serialize (&v);
|
||||||
|
fail_if (tmp == NULL, "couldn't serialize: %s\n", try[i]);
|
||||||
|
fail_unless (gst_value_deserialize (&v, tmp),
|
||||||
|
"couldn't deserialize: %s\n", tmp);
|
||||||
|
g_free (tmp);
|
||||||
|
|
||||||
|
fail_unless (g_str_equal (g_value_get_string (&v), try[i]),
|
||||||
|
"\nserialized : %s\ndeserialized: %s", try[i],
|
||||||
|
g_value_get_string (&v));
|
||||||
|
}
|
||||||
|
g_value_unset (&v);
|
||||||
|
}
|
||||||
|
|
||||||
|
END_TEST;
|
||||||
|
|
||||||
|
START_TEST (test_deserialize_string)
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
gchar *from;
|
||||||
|
gchar *to;
|
||||||
|
} tests[] = {
|
||||||
|
{
|
||||||
|
"", ""}, {
|
||||||
|
"\"\"", ""},
|
||||||
|
/* FAILURES */
|
||||||
|
{
|
||||||
|
"\"", NULL}, /* missing second quote */
|
||||||
|
{
|
||||||
|
"\"Hello\\ World", NULL}, /* missing second quote */
|
||||||
|
{
|
||||||
|
"\"\\", NULL}, /* quote at end, missing second quote */
|
||||||
|
{
|
||||||
|
"\"\\0", NULL}, /* missing second quote */
|
||||||
|
{
|
||||||
|
"\"\\0\"", NULL}, /* unfinished escaped character */
|
||||||
|
{
|
||||||
|
"\" \"", NULL}, /* spaces must be escaped */
|
||||||
|
#if 0
|
||||||
|
/* FIXME 0.9: this test should fail, but it doesn't */
|
||||||
|
{
|
||||||
|
"tüüt", NULL} /* string with special chars must be escaped */
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
guint i;
|
||||||
|
GValue v = { 0, };
|
||||||
|
gboolean ret = TRUE;
|
||||||
|
|
||||||
|
g_value_init (&v, G_TYPE_STRING);
|
||||||
|
for (i = 0; i < G_N_ELEMENTS (tests); i++) {
|
||||||
|
if (gst_value_deserialize (&v, tests[i].from)) {
|
||||||
|
fail_if (tests[i].to == NULL,
|
||||||
|
"I got %s instead of a failure", g_value_get_string (&v));
|
||||||
|
fail_unless (g_str_equal (g_value_get_string (&v), tests[i].to),
|
||||||
|
"\nwanted: %s\ngot : %s", tests[i].to, g_value_get_string (&v));
|
||||||
|
} else {
|
||||||
|
fail_if (tests[i].to != NULL, "failed, but wanted: %s", tests[i].to);
|
||||||
|
ret = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_value_unset (&v);
|
||||||
|
}
|
||||||
|
|
||||||
|
END_TEST;
|
||||||
|
|
||||||
|
Suite *
|
||||||
|
gst_value_suite (void)
|
||||||
|
{
|
||||||
|
Suite *s = suite_create ("GstValue");
|
||||||
|
TCase *tc_chain = tcase_create ("general");
|
||||||
|
|
||||||
|
suite_add_tcase (s, tc_chain);
|
||||||
|
tcase_add_test (tc_chain, test_deserialize_buffer);
|
||||||
|
tcase_add_test (tc_chain, test_string);
|
||||||
|
tcase_add_test (tc_chain, test_deserialize_string);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
int nf;
|
||||||
|
|
||||||
|
Suite *s = gst_value_suite ();
|
||||||
|
SRunner *sr = srunner_create (s);
|
||||||
|
|
||||||
|
gst_check_init (&argc, &argv);
|
||||||
|
|
||||||
|
srunner_run_all (sr, CK_NORMAL);
|
||||||
|
nf = srunner_ntests_failed (sr);
|
||||||
|
srunner_free (sr);
|
||||||
|
|
||||||
|
return nf;
|
||||||
|
}
|
|
@ -29,7 +29,7 @@ DIST_SUBDIRS = \
|
||||||
parse \
|
parse \
|
||||||
plugin refcounting schedulers states threads trigger
|
plugin refcounting schedulers states threads trigger
|
||||||
|
|
||||||
tests_pass = test_gst_init
|
tests_pass =
|
||||||
tests_fail =
|
tests_fail =
|
||||||
tests_ignore =
|
tests_ignore =
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@ tests_pass = \
|
||||||
caps \
|
caps \
|
||||||
value_compare \
|
value_compare \
|
||||||
value_intersect \
|
value_intersect \
|
||||||
value_serialize \
|
|
||||||
audioscale \
|
audioscale \
|
||||||
filtercaps \
|
filtercaps \
|
||||||
eratosthenes \
|
eratosthenes \
|
||||||
|
|
|
@ -1,125 +0,0 @@
|
||||||
#include <gst/gst.h>
|
|
||||||
|
|
||||||
static void
|
|
||||||
test1 (void)
|
|
||||||
{
|
|
||||||
GValue value = { 0 };
|
|
||||||
gboolean ret;
|
|
||||||
|
|
||||||
g_value_init (&value, GST_TYPE_BUFFER);
|
|
||||||
ret = gst_value_deserialize (&value, "1234567890abcdef");
|
|
||||||
g_assert (ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
test_string_serialization (void)
|
|
||||||
{
|
|
||||||
gchar *try[] = {
|
|
||||||
"Dude",
|
|
||||||
"Hi, I'm a string",
|
|
||||||
"tüüüt!"
|
|
||||||
};
|
|
||||||
gchar *tmp;
|
|
||||||
GValue v = { 0, };
|
|
||||||
guint i;
|
|
||||||
gboolean ret = TRUE;
|
|
||||||
|
|
||||||
g_value_init (&v, G_TYPE_STRING);
|
|
||||||
for (i = 0; i < G_N_ELEMENTS (try); i++) {
|
|
||||||
g_value_set_string (&v, try[i]);
|
|
||||||
tmp = gst_value_serialize (&v);
|
|
||||||
if (!tmp) {
|
|
||||||
g_print ("couldn't serialize: %s\n", try[i]);
|
|
||||||
ret = FALSE;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!gst_value_deserialize (&v, tmp)) {
|
|
||||||
g_print ("couldn't deserialize: %s\n", tmp);
|
|
||||||
g_free (tmp);
|
|
||||||
ret = FALSE;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
g_free (tmp);
|
|
||||||
if (!g_str_equal (g_value_get_string (&v), try[i])) {
|
|
||||||
g_print ("serialized : %s\n", try[i]);
|
|
||||||
g_print ("deserialized: %s\n", g_value_get_string (&v));
|
|
||||||
ret = FALSE;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
g_value_unset (&v);
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
test_string_deserialization (void)
|
|
||||||
{
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
gchar *from;
|
|
||||||
gchar *to;
|
|
||||||
} tests[] = {
|
|
||||||
{
|
|
||||||
"", ""}, {
|
|
||||||
"\"\"", ""},
|
|
||||||
/* FAILURES */
|
|
||||||
{
|
|
||||||
"\"", NULL}, /* missing second quote */
|
|
||||||
{
|
|
||||||
"\"Hello\\ World", NULL}, /* missing second quote */
|
|
||||||
{
|
|
||||||
"\"\\", NULL}, /* quote at end, missing second quote */
|
|
||||||
{
|
|
||||||
"\"\\0", NULL}, /* missing second quote */
|
|
||||||
{
|
|
||||||
"\"\\0\"", NULL}, /* unfinished escaped character */
|
|
||||||
{
|
|
||||||
"\" \"", NULL}, /* spaces must be escaped */
|
|
||||||
#if 0
|
|
||||||
/* FIXME 0.9: this test should fail, but it doesn't */
|
|
||||||
{
|
|
||||||
"tüüt", NULL} /* string with special chars must be escaped */
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
guint i;
|
|
||||||
GValue v = { 0, };
|
|
||||||
gboolean ret = TRUE;
|
|
||||||
|
|
||||||
g_value_init (&v, G_TYPE_STRING);
|
|
||||||
for (i = 0; i < G_N_ELEMENTS (tests); i++) {
|
|
||||||
if (gst_value_deserialize (&v, tests[i].from)) {
|
|
||||||
if (tests[i].to == NULL) {
|
|
||||||
g_print ("should fail\n");
|
|
||||||
g_print ("but got: %s\n", g_value_get_string (&v));
|
|
||||||
ret = FALSE;
|
|
||||||
} else if (!g_str_equal (g_value_get_string (&v), tests[i].to)) {
|
|
||||||
g_print ("wanted: %s\n", tests[i].to);
|
|
||||||
g_print ("got : %s\n", g_value_get_string (&v));
|
|
||||||
ret = FALSE;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (tests[i].to != NULL) {
|
|
||||||
g_print ("failed\n");
|
|
||||||
g_print ("but wanted: %s\n", tests[i].to);
|
|
||||||
ret = FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
g_value_unset (&v);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
main (int argc, char *argv[])
|
|
||||||
{
|
|
||||||
gboolean ret = TRUE;
|
|
||||||
|
|
||||||
gst_init (&argc, &argv);
|
|
||||||
|
|
||||||
test1 ();
|
|
||||||
ret &= test_string_serialization ();
|
|
||||||
ret &= test_string_deserialization ();
|
|
||||||
|
|
||||||
return ret ? 0 : 1;
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
#include <gst/gst.h>
|
|
||||||
|
|
||||||
/* This tests that gst_init() doesn't segfault when passed two NULLs as
|
|
||||||
* parameters, and that it doesn't fail if gst_init() happens to get called
|
|
||||||
* a second time. */
|
|
||||||
int
|
|
||||||
main (int argc, char *argv[])
|
|
||||||
{
|
|
||||||
gst_init (NULL, NULL);
|
|
||||||
gst_init (&argc, &argv);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -29,7 +29,7 @@ DIST_SUBDIRS = \
|
||||||
parse \
|
parse \
|
||||||
plugin refcounting schedulers states threads trigger
|
plugin refcounting schedulers states threads trigger
|
||||||
|
|
||||||
tests_pass = test_gst_init
|
tests_pass =
|
||||||
tests_fail =
|
tests_fail =
|
||||||
tests_ignore =
|
tests_ignore =
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@ tests_pass = \
|
||||||
caps \
|
caps \
|
||||||
value_compare \
|
value_compare \
|
||||||
value_intersect \
|
value_intersect \
|
||||||
value_serialize \
|
|
||||||
audioscale \
|
audioscale \
|
||||||
filtercaps \
|
filtercaps \
|
||||||
eratosthenes \
|
eratosthenes \
|
||||||
|
|
|
@ -1,125 +0,0 @@
|
||||||
#include <gst/gst.h>
|
|
||||||
|
|
||||||
static void
|
|
||||||
test1 (void)
|
|
||||||
{
|
|
||||||
GValue value = { 0 };
|
|
||||||
gboolean ret;
|
|
||||||
|
|
||||||
g_value_init (&value, GST_TYPE_BUFFER);
|
|
||||||
ret = gst_value_deserialize (&value, "1234567890abcdef");
|
|
||||||
g_assert (ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
test_string_serialization (void)
|
|
||||||
{
|
|
||||||
gchar *try[] = {
|
|
||||||
"Dude",
|
|
||||||
"Hi, I'm a string",
|
|
||||||
"tüüüt!"
|
|
||||||
};
|
|
||||||
gchar *tmp;
|
|
||||||
GValue v = { 0, };
|
|
||||||
guint i;
|
|
||||||
gboolean ret = TRUE;
|
|
||||||
|
|
||||||
g_value_init (&v, G_TYPE_STRING);
|
|
||||||
for (i = 0; i < G_N_ELEMENTS (try); i++) {
|
|
||||||
g_value_set_string (&v, try[i]);
|
|
||||||
tmp = gst_value_serialize (&v);
|
|
||||||
if (!tmp) {
|
|
||||||
g_print ("couldn't serialize: %s\n", try[i]);
|
|
||||||
ret = FALSE;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!gst_value_deserialize (&v, tmp)) {
|
|
||||||
g_print ("couldn't deserialize: %s\n", tmp);
|
|
||||||
g_free (tmp);
|
|
||||||
ret = FALSE;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
g_free (tmp);
|
|
||||||
if (!g_str_equal (g_value_get_string (&v), try[i])) {
|
|
||||||
g_print ("serialized : %s\n", try[i]);
|
|
||||||
g_print ("deserialized: %s\n", g_value_get_string (&v));
|
|
||||||
ret = FALSE;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
g_value_unset (&v);
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
test_string_deserialization (void)
|
|
||||||
{
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
gchar *from;
|
|
||||||
gchar *to;
|
|
||||||
} tests[] = {
|
|
||||||
{
|
|
||||||
"", ""}, {
|
|
||||||
"\"\"", ""},
|
|
||||||
/* FAILURES */
|
|
||||||
{
|
|
||||||
"\"", NULL}, /* missing second quote */
|
|
||||||
{
|
|
||||||
"\"Hello\\ World", NULL}, /* missing second quote */
|
|
||||||
{
|
|
||||||
"\"\\", NULL}, /* quote at end, missing second quote */
|
|
||||||
{
|
|
||||||
"\"\\0", NULL}, /* missing second quote */
|
|
||||||
{
|
|
||||||
"\"\\0\"", NULL}, /* unfinished escaped character */
|
|
||||||
{
|
|
||||||
"\" \"", NULL}, /* spaces must be escaped */
|
|
||||||
#if 0
|
|
||||||
/* FIXME 0.9: this test should fail, but it doesn't */
|
|
||||||
{
|
|
||||||
"tüüt", NULL} /* string with special chars must be escaped */
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
guint i;
|
|
||||||
GValue v = { 0, };
|
|
||||||
gboolean ret = TRUE;
|
|
||||||
|
|
||||||
g_value_init (&v, G_TYPE_STRING);
|
|
||||||
for (i = 0; i < G_N_ELEMENTS (tests); i++) {
|
|
||||||
if (gst_value_deserialize (&v, tests[i].from)) {
|
|
||||||
if (tests[i].to == NULL) {
|
|
||||||
g_print ("should fail\n");
|
|
||||||
g_print ("but got: %s\n", g_value_get_string (&v));
|
|
||||||
ret = FALSE;
|
|
||||||
} else if (!g_str_equal (g_value_get_string (&v), tests[i].to)) {
|
|
||||||
g_print ("wanted: %s\n", tests[i].to);
|
|
||||||
g_print ("got : %s\n", g_value_get_string (&v));
|
|
||||||
ret = FALSE;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (tests[i].to != NULL) {
|
|
||||||
g_print ("failed\n");
|
|
||||||
g_print ("but wanted: %s\n", tests[i].to);
|
|
||||||
ret = FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
g_value_unset (&v);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
main (int argc, char *argv[])
|
|
||||||
{
|
|
||||||
gboolean ret = TRUE;
|
|
||||||
|
|
||||||
gst_init (&argc, &argv);
|
|
||||||
|
|
||||||
test1 ();
|
|
||||||
ret &= test_string_serialization ();
|
|
||||||
ret &= test_string_deserialization ();
|
|
||||||
|
|
||||||
return ret ? 0 : 1;
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
#include <gst/gst.h>
|
|
||||||
|
|
||||||
/* This tests that gst_init() doesn't segfault when passed two NULLs as
|
|
||||||
* parameters, and that it doesn't fail if gst_init() happens to get called
|
|
||||||
* a second time. */
|
|
||||||
int
|
|
||||||
main (int argc, char *argv[])
|
|
||||||
{
|
|
||||||
gst_init (NULL, NULL);
|
|
||||||
gst_init (&argc, &argv);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
Loading…
Reference in a new issue