]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
add test for read last line
authorBastian Dehn <hhaalo@arcor.de>
Sun, 11 Feb 2024 16:20:51 +0000 (17:20 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 11 Feb 2024 16:23:25 +0000 (17:23 +0100)
src/kds_s2000w_net.c
tests/kds_s2000w_net_tests.c
tests/runtests.c

index 4b8b60d7df1fbb861e716fa0c985459642615445..f6ffb8e08432be72c3a43ae5f4df9bbbfccec9ba 100644 (file)
@@ -30,6 +30,11 @@ int* get_cancel()
        return &cancel;
 }
 
+int* get_readed_lines()
+{
+       return &readed_lines;
+}
+
 int _sane_kds_s2000w_net_find_first_data_byte(const char* data)
 {
        const int header_spaces = 3;
index 305fa878ceffadbb953d3a4e410fb3cf7f089e2f..abcc1467c647f997e5c4096accafc15ee2d8f67c 100644 (file)
@@ -78,4 +78,33 @@ START_TEST(sane_kds_s2000w_net_read_cancel_test)
        free(length);
        length = NULL;
 }
+END_TEST
+
+START_TEST(sane_kds_s2000w_net_read_all_lines_test)
+{
+       int* cancel = get_cancel();
+       *cancel = 0;
+       metadata* current_metadata_ptr = get_current_metadata();
+       char* image = malloc(sizeof(char) * 4);
+       for (int i = 0; i < 3; i++) {
+               image[i] = 0x0a;
+       }
+       image[4] = 0xff;
+       current_metadata.image = image;
+       current_metadata_ptr->lines = 1;
+       int* readed_lines = get_readed_lines();
+       *readed_lines = 0;
+       int* length = malloc(sizeof(int));
+       *length = 0;
+
+       _sane_kds_s2000w_net_read(NULL, NULL, 0, length);
+       SANE_Status status = _sane_kds_s2000w_net_read(NULL, NULL, 0, length);
+
+       ck_assert_int_eq(status, SANE_STATUS_EOF);
+
+       free(length);
+       length = NULL;
+       free(image);
+       image = NULL;
+}
 END_TEST
\ No newline at end of file
index 8170e456dfbfafd6864570138acaa5fd25653c9f..0e71ff1a5c4b40cd5f239072bee61918b08c3f05 100644 (file)
@@ -12,6 +12,7 @@ Suite* first_tests()
        tcase_add_test(tc_core, sane_kds_s2000w_net_find_first_data_byte_test);
        tcase_add_test(tc_core, sane_kds_s2000w_net_read_test);
        tcase_add_test(tc_core, sane_kds_s2000w_net_read_cancel_test);
+       tcase_add_test(tc_core, sane_kds_s2000w_net_read_all_lines_test);
 
        suite_add_tcase(suite, tc_core);