]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
change read only read data without header
authorBastian Dehn <hhaalo@arcor.de>
Mon, 30 Dec 2024 09:41:37 +0000 (10:41 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Mon, 30 Dec 2024 09:41:37 +0000 (10:41 +0100)
src/kds_s2000w_net.c
tests/kds_s2000w_net_read_tests.c
tests/kds_s2000w_net_read_tests.h
tests/kds_s2000w_net_read_tests_run.c

index 5ce6c1a69a2f25dcf46c0ecd382976533a870df6..713e644ad9378c403d0acfe85af457789af76a63 100644 (file)
@@ -214,15 +214,12 @@ SANE_Status _sane_kds_s2000w_net_read(SANE_Handle handle, SANE_Byte* data,
 
        handler* h = (handler*) handle;
 
-       // calc max length
+       // max length
        *length = h->image->size - h->read_info->read_size;
        if (*length > max_length)
                *length = max_length;
 
        // read image
-       if (h->image->data != NULL && h->read_info->read_size <= 0)
-               h->read_info->read_size += _sane_kds_s2000w_net_find_first_data_byte(h->image);
-
        if (h->read_info->read_size < h->image->size) {
                memcpy(data, h->image->data + h->read_info->read_size, *length);
                h->read_info->read_size += *length;
index afd59535c0c1a8d5d20c3d12f6a6d8f92c92010a..dfc184ad7dcb7ce1688f25fcd435bd84485ed5b6 100644 (file)
@@ -55,7 +55,7 @@ void sane_kds_s2000w_net_read_empty_image()
        h = NULL;
 }
 
-void sane_kds_s2000w_net_read_without_header_test()
+void sane_kds_s2000w_net_read_test()
 {
        handler* h = init_handler();
        h->image->size = 65536;
@@ -69,80 +69,11 @@ void sane_kds_s2000w_net_read_without_header_test()
        char* dataptr = malloc(sizeof(char) * maxlen);
        SANE_Int* length = malloc(sizeof(SANE_Int));
 
-       SANE_Status status = _sane_kds_s2000w_net_read(h, (void*) dataptr, maxlen, length);
-
-       assert_int_equal(*length, 0);
-       assert_null(h->image->data);
-       assert_int_equal(h->read_info->read_size, 65536);
-       assert_int_equal(status, SANE_STATUS_EOF);
-
-       free(dataptr);
-       dataptr = NULL;
-       free(length);
-       length = NULL;
-       free(h->image->data);
-       h->image->data = NULL;
-       free_handler(h);
-       h = NULL;
-}
-
-void sane_kds_s2000w_net_read_test()
-{
-       handler* h = init_handler();
-       h->image->size = 65539;
-       h->image->data = malloc(sizeof(char) * 65539);
-       char* imagedata = (char*) h->image->data;
-       for (int i = 0; i < 3; i++) {
-               imagedata[i] = 0x0a;
-       }
-       for (int i = 3; i < 65539; i++) {
-               imagedata[i] = 0xff;
-       }
-
-       SANE_Int maxlen = 65536;
-       char* dataptr = malloc(sizeof(char) * maxlen);
-       SANE_Int* length = malloc(sizeof(SANE_Int));
-
        _sane_kds_s2000w_net_read(h, (void*) dataptr, maxlen, length);
 
        assert_int_equal(*length, 65536);
-       assert_memory_equal(dataptr, h->image->data + 3, 65536);
-       assert_int_equal(h->read_info->read_size, 65539);
-
-       free(dataptr);
-       dataptr = NULL;
-       free(length);
-       length = NULL;
-       free(h->image->data);
-       h->image->data = NULL;
-       free_handler(h);
-       h = NULL;
-}
-
-void sane_kds_s2000w_net_read_bw_test()
-{
-       handler* h = init_handler();
-       h->image->size = 65540;
-       h->image->data = malloc(sizeof(char) * 65540);
-       char* imagedata = (char*) h->image->data;
-       imagedata[0] = 'P';
-       imagedata[1] = '4';
-       for (int i = 2; i < 4; i++) {
-               imagedata[i] = 0x0a;
-       }
-       for (int i = 4; i < 65540; i++) {
-               imagedata[i] = 0xff;
-       }
-
-       SANE_Int maxlen = 65536;
-       char* dataptr = malloc(sizeof(char) * maxlen);
-       SANE_Int* length = malloc(sizeof(SANE_Int));
-
-       _sane_kds_s2000w_net_read(h, (void*) dataptr, maxlen, length);
-
-       assert_int_equal(*length, 65536);
-       assert_memory_equal(dataptr, h->image->data + 4, 65536);
-       assert_int_equal(h->read_info->read_size, 65540);
+       assert_memory_equal(dataptr, h->image->data, 65536);
+       assert_int_equal(h->read_info->read_size, 65536);
 
        free(dataptr);
        dataptr = NULL;
index cce2a3eb3fbc781efee5472fca0ca4885916d0e3..62a339603bc1aa06a300fb95263c2b9a61f59eba 100644 (file)
@@ -8,9 +8,7 @@
 
 void sane_kds_s2000w_net_read_without_data();
 void sane_kds_s2000w_net_read_empty_image();
-void sane_kds_s2000w_net_read_without_header_test();
 void sane_kds_s2000w_net_read_test();
-void sane_kds_s2000w_net_read_bw_test();
 void sane_kds_s2000w_net_read_bytes_per_line_bigger_test();
 
 #endif
\ No newline at end of file
index ba50bd4f288b61fa51217a5a72663ec943b0490d..7468c5e8aa80255fffba9a9277319ca7bc2dc0b4 100644 (file)
@@ -5,9 +5,7 @@ int main()
        const struct CMUnitTest net_read_tests[] = {
                cmocka_unit_test(sane_kds_s2000w_net_read_without_data),
                cmocka_unit_test(sane_kds_s2000w_net_read_empty_image),
-               cmocka_unit_test(sane_kds_s2000w_net_read_without_header_test),
                cmocka_unit_test(sane_kds_s2000w_net_read_test),
-               cmocka_unit_test(sane_kds_s2000w_net_read_bw_test),
                cmocka_unit_test(sane_kds_s2000w_net_read_bytes_per_line_bigger_test)
        };