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
// okay to copy/adapt test ideas
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <assert.h>
#include "print_integer.h"

int main(int argc, char* argv[]) {
    // TEST 1: zero in base 10
    print_integer(0, 10, "");
    fputc('\n', stdout);
    // TEST 2: single digit in base 10
    print_integer(4, 10, "");
    fputc('\n', stdout);

    // TEST 3: two digits in base 10
    print_integer(45, 10, "");
    fputc('\n', stdout);

    // TEST 4: base 8 - single and double digit
    print_integer(06, 8, "");
    fputc('\n', stdout);
    print_integer(051, 8, ""); // leading 0 means 51 is in octal, without the leading 0 its decimal;
    fputc('\n', stdout);

    // TEST 5: three or more digits in base 10
    print_integer(458, 10, "");
    fputc('\n', stdout);

    // base 16 test
    // print_integer(0xa5, 16, ""); // prints af

    // TDD done, now doinggeneral tests

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

© Copyright 2024 Alexander J. Quinn & David Burnett         This content is protected and may not be shared, uploaded, or distributed.