|
| 1 | + -: 0:Source:tst/stream.c |
| 2 | + -: 0:Graph:./cov/test_stream.gcno |
| 3 | + -: 0:Data:./cov/test_stream.gcda |
| 4 | + -: 0:Runs:1 |
| 5 | + -: 1:#include "../inc/test.h" |
| 6 | + -: 2: |
| 7 | +function test_stream called 0 returned 0% blocks executed 0% |
| 8 | + #####: 3:void test_stream (void) { |
| 9 | + #####: 4: printf (BOLD_YELLOW "Unit test starts..." BOLD_MAGENTA " [Stream]\n" RESET_STYLE); |
| 10 | + %%%%%: 4-block 2 |
| 11 | +call 0 never executed |
| 12 | + -: 5: |
| 13 | + #####: 6: char* text = "Hello, World!\n"; |
| 14 | + #####: 7: size_t length = 14; |
| 15 | + -: 8: |
| 16 | + #####: 9: Stream* stream = create_stream (length, (BYTE*) text); |
| 17 | +call 0 never executed |
| 18 | + #####: 10: Stream* ghost_stream = stream; |
| 19 | + -: 11: |
| 20 | + -: 12: // printf ("%lu %lu\n", length, sizeof (stream -> text)); |
| 21 | + -: 13: |
| 22 | + -: 14: // display_stream_details (stream); |
| 23 | + -: 15: |
| 24 | + #####: 16: TEST (NULL != stream, "Checked address non-null"); |
| 25 | +branch 0 never executed (fallthrough) |
| 26 | +branch 1 never executed |
| 27 | + %%%%%: 16-block 5 |
| 28 | +call 2 never executed |
| 29 | + %%%%%: 16-block 6 |
| 30 | +call 3 never executed |
| 31 | + #####: 17: TEST (length == stream -> length, "Checked block-size allocation"); |
| 32 | + %%%%%: 17-block 7 |
| 33 | +branch 0 never executed (fallthrough) |
| 34 | +branch 1 never executed |
| 35 | + %%%%%: 17-block 8 |
| 36 | +call 2 never executed |
| 37 | + %%%%%: 17-block 9 |
| 38 | +call 3 never executed |
| 39 | + #####: 18: TEST (stream == ghost_stream, "Checked address validation"); |
| 40 | + %%%%%: 18-block 10 |
| 41 | +branch 0 never executed (fallthrough) |
| 42 | +branch 1 never executed |
| 43 | + %%%%%: 18-block 11 |
| 44 | +call 2 never executed |
| 45 | + %%%%%: 18-block 12 |
| 46 | +call 3 never executed |
| 47 | + #####: 19: TEST (compare_raw_byte_stream (length, (BYTE*) text, stream -> base_addr), "Matched expected content"); |
| 48 | + %%%%%: 19-block 13 |
| 49 | +call 0 never executed |
| 50 | +branch 1 never executed (fallthrough) |
| 51 | +branch 2 never executed |
| 52 | + %%%%%: 19-block 15 |
| 53 | +call 3 never executed |
| 54 | + %%%%%: 19-block 16 |
| 55 | +call 4 never executed |
| 56 | + -: 20: |
| 57 | + -: 21:// void** stream_addresses = capture_stream_addresses (stream); |
| 58 | + -: 22:// TEST (!is_stream_memory_erased (stream_addresses), "Stream existance check"); |
| 59 | + #####: 23: TEST (stream == ghost_stream, "Checked Stream existance"); |
| 60 | + %%%%%: 23-block 17 |
| 61 | +branch 0 never executed (fallthrough) |
| 62 | +branch 1 never executed |
| 63 | + %%%%%: 23-block 18 |
| 64 | +call 2 never executed |
| 65 | + %%%%%: 23-block 19 |
| 66 | +call 3 never executed |
| 67 | + #####: 24: delete_stream (&stream); |
| 68 | + %%%%%: 24-block 20 |
| 69 | +call 0 never executed |
| 70 | + #####: 25: TEST (stream != ghost_stream, "Checked Stream deletion"); |
| 71 | +branch 0 never executed (fallthrough) |
| 72 | +branch 1 never executed |
| 73 | + %%%%%: 25-block 22 |
| 74 | +call 2 never executed |
| 75 | + %%%%%: 25-block 23 |
| 76 | +call 3 never executed |
| 77 | + -: 26: |
| 78 | + -: 27: //TEST (is_stream_memory_erased (stream_addresses), "Stream deletion check"); |
| 79 | + -: 28:// ERASE (&stream_addresses, 3 * sizeof (void*)); |
| 80 | + -: 29:/* |
| 81 | + -: 30: BYTE* ptr_b = (void*) stream; |
| 82 | + -: 31: BYTE* ptr_adr = (void*) (stream -> address); |
| 83 | + -: 32: BYTE* ptr_b_f = (void*) stream; |
| 84 | + -: 33: |
| 85 | + -: 34: for (size_t i = 0; i < sizeof (Stream); i++) { |
| 86 | + -: 35: printf("%02x ", *ptr_b); |
| 87 | + -: 36: ptr_b = ptr_b + 1; |
| 88 | + -: 37: } |
| 89 | + -: 38: |
| 90 | + -: 39: printf("\n"); |
| 91 | + -: 40: |
| 92 | + -: 41: delete_stream (&stream); |
| 93 | + -: 42: |
| 94 | + -: 43: for (size_t i = 0; i < sizeof (size_t); i++) { |
| 95 | + -: 44: printf("%02x ", *ptr_adr); |
| 96 | + -: 45: ptr_adr = ptr_adr + 1; |
| 97 | + -: 46: } |
| 98 | + -: 47: |
| 99 | + -: 48: printf("\n"); |
| 100 | + -: 49: |
| 101 | + -: 50: for (size_t i = 0; i < sizeof (Stream); i++) { |
| 102 | + -: 51: printf ("%02x ", *ptr_b_f); |
| 103 | + -: 52: ptr_b_f = ptr_b_f + 1; |
| 104 | + -: 53: } |
| 105 | + -: 54: |
| 106 | + -: 55: printf("\n"); |
| 107 | + -: 56:*/ |
| 108 | + -: 57:// TEST (NULL == stream, "Address nullified check"); |
| 109 | + -: 58:// TEST (sizeof (int*) == sizeof (stream), "De-allocated block-size check"); |
| 110 | + -: 59:// TEST (NULL == stream, "Address nullify check"); |
| 111 | + -: 60:// TEST (ptr != vptr, "Address validation check"); |
| 112 | + -: 61:// TEST (n != *((int*) vptr), "Content check"); |
| 113 | + -: 62:/* |
| 114 | + -: 63: Stream* str1 = create_stream (5, "Hello"); |
| 115 | + -: 64: Stream* str2 = create_stream (5, "World"); |
| 116 | + -: 65: stream = concatenate_streams (2, str1, str2); |
| 117 | + -: 66: TEST (stream -> length == str1 -> length + str2 -> length, "Checked concatenated stream lengths"); |
| 118 | + -: 67: ghost_stream = create_stream (10, "HelloWorld"); |
| 119 | + -: 68: TEST (Cmp_Different != compare_streams (stream, ghost_stream), "Matched concatenated streams"); |
| 120 | + -: 69: delete_stream (&ghost_stream); |
| 121 | + -: 70: delete_stream (&stream); |
| 122 | + -: 71: delete_stream (&str1); |
| 123 | + -: 72: delete_stream (&str2); |
| 124 | + -: 73: stream = create_stream (5, "Radar"); |
| 125 | + -: 74: TEST (1 == get_char_first_index (stream, 'a'), "Matched first index of character in given Stream"); |
| 126 | + -: 75: TEST (3 == get_char_last_index (stream, 'a'), "Matched last index of character in given Stream"); |
| 127 | + -: 76: delete_stream (&stream); |
| 128 | + -: 77:*/ |
| 129 | + #####: 78: printf (BOLD_YELLOW "...Unit test ends!" BOLD_MAGENTA " [Stream]\n" RESET_STYLE); |
| 130 | + %%%%%: 78-block 24 |
| 131 | +call 0 never executed |
| 132 | + #####: 79:} |
0 commit comments