| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include <stdlib.h> | ||
| 2 | #include <stdio.h> | ||
| 3 | #include <assert.h> | ||
| 4 | |||
| 5 | #include "image.h" | ||
| 6 | |||
| 7 | #define TEST_BEGIN \ | ||
| 8 | puts(__FUNCTION__); \ | ||
| 9 | { | ||
| 10 | |||
| 11 | #define TEST_END \ | ||
| 12 | } | ||
| 13 | |||
| 14 | 1 | void test_image_create_zero_width(void) { | |
| 15 | 1 | TEST_BEGIN | |
| 16 | 1 | image_t image = image_create(0, 100, 4); | |
| 17 |
1/2✗ Branch 0 (4→5) not taken.
✓ Branch 1 (4→6) taken 1 times.
|
1 | assert(image.width == 0); |
| 18 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | assert(image.height == 0); |
| 19 |
1/2✗ Branch 0 (8→9) not taken.
✓ Branch 1 (8→10) taken 1 times.
|
1 | assert(image.bpp == 0); |
| 20 |
1/2✗ Branch 0 (10→11) not taken.
✓ Branch 1 (10→12) taken 1 times.
|
1 | assert(image.pixels == NULL); |
| 21 | TEST_END | ||
| 22 | 1 | } | |
| 23 | |||
| 24 | 1 | void test_image_create_too_wide(void) { | |
| 25 | 1 | TEST_BEGIN | |
| 26 | 1 | image_t image = image_create(MAX_WIDTH+1, 100, 4); | |
| 27 |
1/2✗ Branch 0 (4→5) not taken.
✓ Branch 1 (4→6) taken 1 times.
|
1 | assert(image.width == 0); |
| 28 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | assert(image.height == 0); |
| 29 |
1/2✗ Branch 0 (8→9) not taken.
✓ Branch 1 (8→10) taken 1 times.
|
1 | assert(image.bpp == 0); |
| 30 |
1/2✗ Branch 0 (10→11) not taken.
✓ Branch 1 (10→12) taken 1 times.
|
1 | assert(image.pixels == NULL); |
| 31 | TEST_END | ||
| 32 | 1 | } | |
| 33 | |||
| 34 | 1 | void test_image_create_zero_height(void) { | |
| 35 | 1 | TEST_BEGIN | |
| 36 | 1 | image_t image = image_create(100, 0, 4); | |
| 37 |
1/2✗ Branch 0 (4→5) not taken.
✓ Branch 1 (4→6) taken 1 times.
|
1 | assert(image.width == 0); |
| 38 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | assert(image.height == 0); |
| 39 |
1/2✗ Branch 0 (8→9) not taken.
✓ Branch 1 (8→10) taken 1 times.
|
1 | assert(image.bpp == 0); |
| 40 |
1/2✗ Branch 0 (10→11) not taken.
✓ Branch 1 (10→12) taken 1 times.
|
1 | assert(image.pixels == NULL); |
| 41 | TEST_END | ||
| 42 | 1 | } | |
| 43 | |||
| 44 | 1 | void test_image_create_wrong_image_type(void) { | |
| 45 | 1 | TEST_BEGIN | |
| 46 | 1 | image_t image = image_create(100, 100, 0); | |
| 47 |
1/2✗ Branch 0 (4→5) not taken.
✓ Branch 1 (4→6) taken 1 times.
|
1 | assert(image.width == 0); |
| 48 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | assert(image.height == 0); |
| 49 |
1/2✗ Branch 0 (8→9) not taken.
✓ Branch 1 (8→10) taken 1 times.
|
1 | assert(image.bpp == 0); |
| 50 |
1/2✗ Branch 0 (10→11) not taken.
✓ Branch 1 (10→12) taken 1 times.
|
1 | assert(image.pixels == NULL); |
| 51 | TEST_END | ||
| 52 | 1 | } | |
| 53 | |||
| 54 | 1 | void test_image_create_grayscale(void) { | |
| 55 | 1 | TEST_BEGIN | |
| 56 | 1 | image_t image = image_create(100, 100, GRAYSCALE); | |
| 57 |
1/2✗ Branch 0 (4→5) not taken.
✓ Branch 1 (4→6) taken 1 times.
|
1 | assert(image.pixels != NULL); |
| 58 | 1 | free(image.pixels); | |
| 59 | TEST_END | ||
| 60 | 1 | } | |
| 61 | |||
| 62 | 1 | void test_image_create_rgba(void) { | |
| 63 | 1 | TEST_BEGIN | |
| 64 | 1 | image_t image = image_create(100, 100, RGBA); | |
| 65 |
1/2✗ Branch 0 (4→5) not taken.
✓ Branch 1 (4→6) taken 1 times.
|
1 | assert(image.pixels != NULL); |
| 66 | 1 | free(image.pixels); | |
| 67 | TEST_END | ||
| 68 | 1 | } | |
| 69 | |||
| 70 | 1 | int main(void) { | |
| 71 | 1 | test_image_create_zero_width(); | |
| 72 | 1 | test_image_create_too_wide(); | |
| 73 | 1 | test_image_create_zero_height(); | |
| 74 | 1 | test_image_create_wrong_image_type(); | |
| 75 | 1 | test_image_create_grayscale(); | |
| 76 | 1 | test_image_create_rgba(); | |
| 77 | 1 | return 0; | |
| 78 | } | ||
| 79 | |||
| 80 |