]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
add set option int test
authorBastian Dehn <hhaalo@arcor.de>
Sat, 25 Oct 2025 16:44:44 +0000 (18:44 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sat, 25 Oct 2025 16:44:44 +0000 (18:44 +0200)
tests/kds_s2000w_net_set_opt_tests.c

index 7db462f225c1acd7da990b34092349c3bd0b73f2..e6bea79e8b3ba64741ea16178cfd12df2224433b 100644 (file)
@@ -126,6 +126,44 @@ void kds_s2000w_net_set_option_string(void** state)
        info = NULL;
 }
 
+void kds_s2000w_net_set_option_int(void** state)
+{
+       int32_t* set_value = malloc(sizeof(int32_t));
+       if (set_value == NULL)
+               return;
+
+       *set_value = 5;
+       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_kds_s2000w_net_control_option(h, 15, 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, FOREGROUND_BOLDNESS_AGGRESSIVENESS);
+       const char* value = json_object_get_string(value_object);
+
+       assert_int_equal(value, 5);
+
+       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;
+}
+
 int main()
 {
        const struct CMUnitTest net_tests[] = {