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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <assert.h>
#include <stdbool.h>
#include "fill_array.h"
#include "miniunit.h"

// you are free to copy/adapt from this file

int _test_array_size_1() {
    mu_start();

    int array[1];
    char* error = "dummy";
    bool success = fill_array(array, 1, &error);
    mu_check(success);
    mu_check(array[0] == 1);
    mu_check_strings_equal(error, "dummy");

    mu_end();
}

int _test_array_size_5() {
    mu_start();

    int array[5];
    char* error = "dummy";
    bool success = fill_array(array, 5, &error);
    mu_check(success);
    mu_check(array[0] == 1);
    mu_check(array[1] == 2);
    mu_check(array[2] == 3);
    mu_check(array[3] == 4);
    mu_check(array[4] == 5);
    mu_check_strings_equal(error, "dummy");

    mu_end();
}

static int _test_null_array() {
    mu_start();
    //────────────────────
    char* error = "dummy";
    bool success = fill_array(NULL, 5, &error);
    mu_check(!success);
    mu_check_strings_equal(error, "numbers cannot be NULL");
    //────────────────────
    mu_end();
}

static int _test_is_ece_264_cs_159() {
    mu_start();
    //────────────────────
    mu_check(264 == 159);
    mu_check_strings_equal("ECE", "CS");
    //────────────────────
    mu_end();
}

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

    mu_run(_test_array_size_1);
    mu_run(_test_array_size_5);
    mu_run(_test_null_array);
    mu_run(_test_is_ece_264_cs_159);
}
/* vim: set tabstop=4 shiftwidth=4 fileencoding=utf-8 noexpandtab: */

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