From: Bastian Dehn Date: Sat, 25 Oct 2025 17:58:55 +0000 (+0200) Subject: add test for set br x X-Git-Tag: v1.1.16^2~1^2~2 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=df24a81b1f1761dd5334a75acab820387b244d85;p=sane-kds-s2000w-net.git add test for set br x --- diff --git a/tests/kds_s2000w_net_set_opt_tests.c b/tests/kds_s2000w_net_set_opt_tests.c index 550b59a..5e1d6bf 100644 --- a/tests/kds_s2000w_net_set_opt_tests.c +++ b/tests/kds_s2000w_net_set_opt_tests.c @@ -166,6 +166,45 @@ void kds_s2000w_net_set_option_int(void** state) set_value = NULL; } +void kds_s2000w_net_set_option_int_br_x(void** state) +{ + int32_t* set_value = malloc(sizeof(int32_t)); + if (set_value == NULL) + return; + + *set_value = 300; + response_t* resp = (response_t*) *state; + handler_t* h = kds_s2000w_handler_init(); + response_t* set_opt_resp = kds_s2000w_client_response_init(); + set_opt_resp->code = 200; + + will_return(mock_response, resp); + will_return(__wrap_kds_s2000w_client_get_option, 0); + will_return(mock_response, set_opt_resp); + will_return(__wrap_kds_s2000w_client_set_option, 0); + will_return(mock_response, set_opt_resp); + will_return(__wrap_kds_s2000w_client_set_option, 0); + expect_function_call(__wrap_kds_s2000w_client_get_option); + expect_function_call(__wrap_kds_s2000w_client_set_option); + expect_function_call(__wrap_kds_s2000w_client_set_option); + + SANE_Status status = sane_kds_s2000w_net_control_option(h, 11, SANE_ACTION_SET_VALUE, set_value, NULL); + + json_object* config = json_object_object_get(h->scanner_config, "Configuration"); + json_object* value_object = json_object_object_get(config, IMAGE_WIDTH); + int32_t value = json_object_get_int(value_object); + + assert_int_equal(status, SANE_STATUS_GOOD); + assert_int_equal(value, 10); + + kds_s2000w_client_response_free(set_opt_resp); + set_opt_resp = NULL; + kds_s2000w_handler_free(h); + h = NULL; + free(set_value); + set_value = NULL; +} + void kds_s2000w_net_set_option_int_word_list(void** state) { int32_t* set_value = malloc(sizeof(int32_t)); @@ -303,6 +342,7 @@ int main() const struct CMUnitTest net_tests[] = { cmocka_unit_test_setup_teardown(kds_s2000w_net_set_option_string, setup_default_option, teardown_default_option), cmocka_unit_test_setup_teardown(kds_s2000w_net_set_option_int, setup_default_option, teardown_default_option), + cmocka_unit_test_setup_teardown(kds_s2000w_net_set_option_int_br_x, setup_default_option, teardown_default_option), cmocka_unit_test_setup_teardown(kds_s2000w_net_set_option_int_word_list, setup_default_option, teardown_default_option), cmocka_unit_test_setup_teardown(kds_s2000w_net_set_invalid_option_string, setup_default_option, teardown_default_option), cmocka_unit_test_setup_teardown(kds_s2000w_net_set_invalid_option_int, setup_default_option, teardown_default_option),