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
#include <stdio.h>
#include <stdlib.h>

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

typedef struct {
    uint8_t r;
    uint8_t g;
    uint8_t b;
} Color;

bool _check_pixel_color(uint8_t* pixels, size_t x, size_t y, size_t w, Color color) {
    size_t offset = _get_offset(x, y, w);
    return (pixels[offset + 2] == color.r) &&
           (pixels[offset + 1] == color.g) &&
           (pixels[offset + 0] == color.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);
    Color purple = { .r=0xff, .g=0xff, .b=0xff };
    mu_check(_check_pixel(pixels, 0, 0, purple));
    //────────────────────────────────────────
    mu_end();
}


// If using miniunit, redirect all output (including stderr) to expected.txt.
//
//    $ ./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.