From: Bastian Dehn Date: Tue, 12 Mar 2024 19:50:57 +0000 (+0100) Subject: add test for load option zero X-Git-Tag: v1.0.0^2~102 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=21d83876aae4a2a70720e925df64abb250d9975a;p=sane-kds-s2000w-net.git add test for load option zero --- diff --git a/src/kds_s2000w_client.c b/src/kds_s2000w_client.c index ef189e1..912a671 100644 --- a/src/kds_s2000w_client.c +++ b/src/kds_s2000w_client.c @@ -6,6 +6,7 @@ #include "kds_s2000w_debug.h" #include "kds_s2000w_config.h" +#ifndef TEST program_config p_config; void _kds_s2000w_client_load_config() @@ -56,8 +57,6 @@ void kds_s2000w_client_response_free(response* response) if (response == NULL) return; - free(response->data); - response->data = NULL; free(response); response = NULL; } @@ -512,4 +511,5 @@ int kds_s2000w_client_set_option(int64_t sessionid, response* response) curl = NULL; return result; -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/src/kds_s2000w_handler_opts.c b/src/kds_s2000w_handler_opts.c index 6232f8d..cc47e53 100644 --- a/src/kds_s2000w_handler_opts.c +++ b/src/kds_s2000w_handler_opts.c @@ -72,6 +72,7 @@ void kds_s2000w_handler_get_option(handler* h, int option, void* value, int* inf config = json_object_object_get(resp_config, "Configuration"); int* int_value_ptr = (int*) value; *int_value_ptr = json_object_object_length(config) + COUNT_CUSTOM_OPTIONS; + debug_printf_int(DEBUG, "option numbers", *int_value_ptr); break; case 2: value_object = json_object_object_get(config, "ScanSource"); diff --git a/tests/kds_s2000w_net_tests.c b/tests/kds_s2000w_net_tests.c index 31d6153..8f1ca3b 100644 --- a/tests/kds_s2000w_net_tests.c +++ b/tests/kds_s2000w_net_tests.c @@ -1,9 +1,20 @@ +#define TEST #include #include #include "kds_s2000w_net_tests.h" +#include "../src/kds_s2000w_client.h" #include "../src/kds_s2000w_net.h" #include "../src/kds_s2000w_handler.h" +int kds_s2000w_client_get_option(int64_t sessionid, response* response) +{ + response->data = "{\"Configuration\":{\"testproperty\": 0, \"testproperty2\": 0}}"; + response->code = 200; + response->size = sizeof(response->data); + + return 0; +} + START_TEST(kds_s2000w_net_get_parameters_with_image_data) { handler* h = init_handler(); @@ -78,6 +89,19 @@ START_TEST(kds_s2000w_net_get_select_fd) } END_TEST +START_TEST(sane_kds_s2000w_net_control_option_zero) +{ + handler* h = init_handler(); + int value = 0; + + _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &value, NULL); + + ck_assert_int_eq(value, 4); + free_handler(h); + h = NULL; +} +END_TEST + Suite* net_tests() { Suite* net_tests_suite = suite_create("kds_s2000w_net"); @@ -88,6 +112,7 @@ Suite* net_tests() tcase_add_test(net_tests, kds_s2000w_net_get_parameters_with_image_data); tcase_add_test(net_tests, kds_s2000w_net_set_io_mode); tcase_add_test(net_tests, kds_s2000w_net_get_select_fd); + tcase_add_test(net_tests, sane_kds_s2000w_net_control_option_zero); suite_add_tcase(net_tests_suite, net_tests); return net_tests_suite; } \ No newline at end of file