1
0
mirror of https://gitlab.xiph.org/xiph/ezstream.git synced 2024-11-03 04:17:18 -05:00

Test and fix cfg_*_get()

This commit is contained in:
Moritz Grimm 2015-05-16 00:39:36 +02:00
parent 1d02b841f0
commit 876660fc17
3 changed files with 39 additions and 1 deletions

View File

@ -87,6 +87,8 @@ cfg_decoder_get(const char *name)
d->name = xstrdup(name);
TAILQ_INIT(&d->exts);
TAILQ_INSERT_TAIL(&cfg_decoders, d, entry);
return (d);
}

View File

@ -73,6 +73,8 @@ cfg_encoder_get(const char *name)
e = xcalloc(1UL, sizeof(*e));
e->name = xstrdup(name);
TAILQ_INSERT_TAIL(&cfg_encoders, e, entry);
return (e);
}

View File

@ -449,11 +449,37 @@ START_TEST(test_metadata_no_updates)
}
END_TEST
START_TEST(test_decoder_get)
{
cfg_decoder_t dec, dec2;
ck_assert_ptr_eq(cfg_decoder_get(NULL), NULL);
ck_assert_ptr_eq(cfg_decoder_get(""), NULL);
dec = cfg_decoder_get("TeSt");
dec2 = cfg_decoder_get("test");
ck_assert_ptr_eq(dec, dec2);
}
END_TEST
START_TEST(test_encoder_get)
{
cfg_encoder_t enc, enc2;
ck_assert_ptr_eq(cfg_encoder_get(NULL), NULL);
ck_assert_ptr_eq(cfg_encoder_get(""), NULL);
enc = cfg_encoder_get("TeSt");
enc2 = cfg_encoder_get("test");
ck_assert_ptr_eq(enc, enc2);
}
END_TEST
Suite *
cfg_suite(void)
{
Suite *s;
TCase *tc_core;
TCase *tc_core, *tc_decoder, *tc_encoder;
s = suite_create("Config");
@ -501,6 +527,14 @@ cfg_suite(void)
tcase_add_test(tc_core, test_metadata_no_updates);
suite_add_tcase(s, tc_core);
tc_decoder = tcase_create("Decoder");
tcase_add_test(tc_decoder, test_decoder_get);
suite_add_tcase(s, tc_decoder);
tc_encoder = tcase_create("Encoder");
tcase_add_test(tc_encoder, test_encoder_get);
suite_add_tcase(s, tc_encoder);
return (s);
}