int setup(void** state)
{
response** response_list = malloc(sizeof(response*) * 4);
+ if (response_list == NULL)
+ return 1;
response_list[0] = kds_s2000w_client_response_init();
response_list[0]->code = 200;
response_list[1] = kds_s2000w_client_response_init();
response_list[2]->size = 17;
response_list[2]->data = malloc(sizeof(char) * 17);
char* image_data = (char*) response_list[2]->data;
+ if (image_data == NULL) {
+ for (int i = 0; i < 4; i++) {
+ free(response_list[i]);
+ response_list[i] = NULL;
+ }
+ free(response_list);
+ response_list = NULL;
+ return 1;
+ }
image_data[0] = 0x50;
image_data[1] = 0x36;
image_data[2] = 0x0a;
void kds_s2000w_net_init_test()
{
SANE_Int* version = malloc(sizeof(SANE_Int));
+ if (version == NULL)
+ return;
SANE_Status status = sane_kds_s2000w_net_init(version, NULL);
void kds_s2000w_net_get_devices_test()
{
SANE_Device*** device_list = malloc(sizeof(SANE_Device**));
+ if (device_list == NULL)
+ return;
sane_kds_s2000w_net_get_devices(device_list, 0);
void kds_s2000w_net_get_devices_only_remote_test()
{
SANE_Device*** device_list = malloc(sizeof(SANE_Device**));
+ if (device_list == NULL)
+ return;
SANE_Status result = sane_kds_s2000w_net_get_devices(device_list, 1);
void sane_kds_s2000w_net_get_parameter_color_test()
{
handler* h = kds_s2000w_handler_init();
+ if (h == NULL)
+ return;
const char* config = "{\"Configuration\":{\"ColorMode\":\"Color\"}}";
h->current_scanner_config = json_tokener_parse(config);
h->image->size = 17;
h->image->data = malloc(sizeof(char) * 17);
char* image_data = (char*) h->image->data;
+ if (image_data == NULL) {
+ kds_s2000w_handler_free(h);
+ h = NULL;
+ return;
+ }
image_data[0] = 0x50;
image_data[1] = 0x36;
image_data[2] = 0x0a;
}
SANE_Parameters* params = malloc(sizeof(SANE_Parameters));
+ if (params == NULL) {
+ free(image_data);
+ image_data = NULL;
+ kds_s2000w_handler_free(h);
+ h = NULL;
+ return;
+ }
SANE_Status status = sane_kds_s2000w_net_get_parameters(h, params);
void sane_kds_s2000w_net_get_parameter_bw_test()
{
handler* h = kds_s2000w_handler_init();
+ if (h == NULL)
+ return;
const char* config = "{\"Configuration\":{\"ColorMode\":\"Color\"}}";
h->current_scanner_config = json_tokener_parse(config);
h->image->size = 17;
h->image->data = malloc(sizeof(char) * 17);
char* image_data = (char*) h->image->data;
+ if (image_data == NULL) {
+ kds_s2000w_handler_free(h);
+ h = NULL;
+ return;
+ }
image_data[0] = 0x50;
image_data[1] = 0x34;
image_data[2] = 0x0a;
}
SANE_Parameters* params = malloc(sizeof(SANE_Parameters));
+ if (params == NULL) {
+ free(image_data);
+ image_data = NULL;
+ kds_s2000w_handler_free(h);
+ h = NULL;
+ return;
+ }
SANE_Status status = sane_kds_s2000w_net_get_parameters(h, params);
void sane_kds_s2000w_net_open_test()
{
response* resp = kds_s2000w_client_response_init();
+ if (resp == NULL)
+ return;
const char* responsedata = "{\"SessionId\":\"1251877821\"}";
resp->size = 27;
resp->data = malloc(resp->size);
will_return(__wrap_kds_s2000w_client_open_session, 0);
expect_function_call(__wrap_kds_s2000w_client_open_session);
void** hlist = malloc(sizeof(void*));
+ if (hlist == NULL) {
+ kds_s2000w_client_response_free(resp);
+ resp = NULL;
+ return;
+ }
SANE_Status status = sane_kds_s2000w_net_open("kds_s2000w_net", hlist);
handler* h = (handler*) *hlist;