1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <stdio.h>
#include <stdlib.h>

// from OFFICE HOURS on Sat 4/6/2019

size_t _get_row_size_bytes(size_t w) {
    size_t row_size_bytes = w * 3;
    row_size_bytes += ▒▒▒▒▒;  // add padding
    return row_size_bytes;
}

size_t _get_offset(size_t x, size_t y, size_t w) {
    return ▒▒▒;
}

bool _check_pixel(uint8_t* pixels, size_t x, size_t y, size_t w, uint8_t r, uint8_t g, uint8_t b) {
    size_t offset = _get_offset(x, y);
    return (pixels[offset + 2] == r) &&
           (pixels[offset + 1] == g) &&
           (pixels[offset + 0] == b);
}

int test_one_pixel_image() {
    mu_start();
    //────────────────────────────────────────
    BMPImage img = _create_one_pixel_img();
    mu_check(img.header.width  == 1);
    mu_check(img.header.height == 1);
    mu_check(_check_pixel(pixels, 0, 0, 1, 0x80, 0x00, 0xff));  // must be purple
    //────────────────────────────────────────
    mu_end();
}


// If using miniunit:
// $ ./test_bmp &> expected.txt

int main(int argc, char* argv[]) {

    return EXIT_SUCCESS;
}
/* vim: set tabstop=4 shiftwidth=4 fileencoding=utf-8 noexpandtab: */

© Copyright 2019 Alexander J. Quinn         This content is protected and may not be shared, uploaded, or distributed.