From 34bdab6a36db1eca0df3af0bdb6d7b4a5ef161f4 Mon Sep 17 00:00:00 2001 From: Moritz Grimm Date: Thu, 21 May 2015 23:25:05 +0200 Subject: [PATCH] Fix cfg_get_metadata_program() and add tests when NULL is expected from getters --- src/cfg.c | 2 +- tests/check_cfg.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cfg.c b/src/cfg.c index 9764285..2851f77 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -757,7 +757,7 @@ cfg_get_media_stream_once(void) const char * cfg_get_metadata_program(void) { - return (cfg.metadata.program); + return (cfg.metadata.program[0] ? cfg.metadata.program : NULL); } const char * diff --git a/tests/check_cfg.c b/tests/check_cfg.c index 6f21e9f..9f1e8ce 100644 --- a/tests/check_cfg.c +++ b/tests/check_cfg.c @@ -174,6 +174,7 @@ END_TEST START_TEST(test_program_config_file) { + ck_assert_ptr_eq(cfg_get_program_config_file(), NULL); TEST_STRLCPY(cfg_set_program_config_file, cfg_get_program_config_file, PATH_MAX); } @@ -247,6 +248,7 @@ END_TEST START_TEST(test_server_user) { + ck_assert_str_eq(cfg_get_server_user(), DEFAULT_USER); TEST_STRLCPY(cfg_set_server_user, cfg_get_server_user, UCREDS_SIZE); } END_TEST @@ -415,6 +417,7 @@ END_TEST START_TEST(test_metadata_program) { + ck_assert_ptr_eq(cfg_get_metadata_program(), NULL); TEST_STRLCPY(cfg_set_metadata_program, cfg_get_metadata_program, PATH_MAX); }