tests/check/libs/audio.c: Add simple unit test to make sure GstValue intersection of channel layouts works the way I ...

Original commit message from CVS:
* tests/check/libs/audio.c: (init_value_to_channel_layout),
(test_channel_layout_value_intersect), (audio_suite):
Add simple unit test to make sure GstValue intersection
of channel layouts works the way I think it does.
This commit is contained in:
Tim-Philipp Müller 2007-10-31 12:30:28 +00:00
parent ffa52e2eac
commit cfecc1f025
2 changed files with 64 additions and 0 deletions

View file

@ -1,3 +1,10 @@
2007-10-31 Tim-Philipp Müller <tim at centricular dot net>
* tests/check/libs/audio.c: (init_value_to_channel_layout),
(test_channel_layout_value_intersect), (audio_suite):
Add simple unit test to make sure GstValue intersection
of channel layouts works the way I think it does.
2007-10-30 Stefan Kost <ensonic@users.sf.net>
* docs/libs/gst-plugins-base-libs-sections.txt:

View file

@ -456,6 +456,62 @@ GST_START_TEST (test_buffer_clipping_samples)
GST_END_TEST;
static void
init_value_to_channel_layout (GValue * val, GstAudioChannelPosition pos1,
GstAudioChannelPosition pos2)
{
GValue pos = { 0, };
g_value_init (val, GST_TYPE_ARRAY);
g_value_init (&pos, GST_TYPE_AUDIO_CHANNEL_POSITION);
g_value_set_enum (&pos, pos1);
gst_value_array_append_value (val, &pos);
g_value_set_enum (&pos, pos2);
gst_value_array_append_value (val, &pos);
g_value_unset (&pos);
}
GST_START_TEST (test_channel_layout_value_intersect)
{
GValue layout = { 0, };
GValue list = { 0, };
GValue res = { 0, };
g_value_init (&list, GST_TYPE_LIST);
init_value_to_channel_layout (&layout, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT);
gst_value_list_append_value (&list, &layout);
g_value_unset (&layout);
init_value_to_channel_layout (&layout, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT);
gst_value_list_append_value (&list, &layout);
g_value_unset (&layout);
init_value_to_channel_layout (&layout, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT);
/* we should get the second layout in the list, as it matches the input */
fail_unless (gst_value_intersect (&res, &layout, &list));
g_value_unset (&layout);
fail_unless (GST_VALUE_HOLDS_ARRAY (&res));
fail_unless_equals_int (gst_value_array_get_size (&res), 2);
fail_unless_equals_int (g_value_get_enum (gst_value_array_get_value (&res,
0)), GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT);
fail_unless_equals_int (g_value_get_enum (gst_value_array_get_value (&res,
1)), GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT);
g_value_unset (&res);
/* this (with rear position) should not yield any results */
init_value_to_channel_layout (&layout, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT);
fail_if (gst_value_intersect (&res, &layout, &list));
g_value_unset (&layout);
g_value_unset (&list);
}
GST_END_TEST;
static Suite *
audio_suite (void)
{
@ -466,6 +522,7 @@ audio_suite (void)
tcase_add_test (tc_chain, test_multichannel_checks);
tcase_add_test (tc_chain, test_buffer_clipping_time);
tcase_add_test (tc_chain, test_buffer_clipping_samples);
tcase_add_test (tc_chain, test_channel_layout_value_intersect);
return s;
}