]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
add empty config test
authorBastian Dehn <hhaalo@arcor.de>
Sat, 2 Mar 2024 18:53:43 +0000 (19:53 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sat, 2 Mar 2024 18:54:32 +0000 (19:54 +0100)
src/kds_s2000w_config.c
tests/kds_s2000w_read_config_tests.c
tests/runtests.c

index cd691a8ce8588c635311e2631790570896262762..5fb92ce26a4d22679e8f823d6ed9e5215718c30f 100644 (file)
@@ -139,6 +139,11 @@ void get_value(config_line* line, config_value* value)
 
 void loadConfig(program_config* config, const char* config_stream)
 {
+       config->scanner_url = NULL;
+       if (strlen(config_stream) == 0) {
+               return;
+       }
+
        config_line line;
        line.length = 0;
        line.line = NULL;
index 7ad0d12a7cc218953671a264414f1613e9b50287..bf34800dc39d5cd0bb78b5f4958cc1e322ba6a38 100644 (file)
@@ -15,4 +15,18 @@ START_TEST(kds_s2000w_config_read_parameter)
        free(config);
        config = NULL;
 }
+END_TEST
+
+START_TEST(kds_s2000w_config_read_empty_config)
+{
+       const char* input_stream = "";
+
+       program_config* config = malloc(sizeof(program_config));
+       loadConfig(config, input_stream);
+
+       ck_assert_ptr_null(config->scanner_url);
+
+       free(config);
+       config = NULL;
+}
 END_TEST
\ No newline at end of file
index dd11d83b61c2947bde965ef3189dcbac9f4da472..2e79947aa12cd83c5276d9fa6640f77bfcbc5338 100644 (file)
@@ -51,6 +51,7 @@ Suite* config_read()
        Suite* read_config = suite_create("kds_s2000w_net_read_config");
 
        TCase* net_config_read = tcase_create("read config");
+       tcase_add_test(net_config_read, kds_s2000w_config_read_empty_config);
        tcase_add_test(net_config_read, kds_s2000w_config_read_parameter);
        suite_add_tcase(read_config, net_config_read);