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>
#include <stdbool.h>
#include <assert.h>
#include "print_integer.h"

// TEST FILE

int main(int argc, char* argv[]) {
    // TEST 1:  0 in base 10
    print_integer(0, 10, "");  // print zero in base 10 with no prefix
                               // - DOUBLE QUOTES for a string literal
    fputc('\n', stdout);  // Write the newline character ('\n') to stdout.
                          // - SINGLE QUOTES for a character constant
    
    // TEST 2:  single digit number in base 10
    print_integer(5, 10, "");
    fputc('\n', stdout);

    // PREFIX
    //print_integer(-5, 10, '$');  // prefix should be a string literal ("$") not '$'
    print_integer(-5, 10, "$");  // prefix should be a string literal ("$") not '$'
    fputc('\n', stdout);
    fputc("\n", stdout);

    return EXIT_SUCCESS;
}
/*
test_print_integer.c: In function ‘main’:
test_print_integer.c:21:24: warning: passing argument 3 of ‘print_integer’ makes pointer from integer without a cast [-Wint-conversion]
  print_integer(-5, 10, '$');  // prefix should be a string literal ("$") not '$'
                        ^~~
In file included from test_print_integer.c:5:
print_integer.h:7:44: note: expected ‘char *’ but argument is of type ‘int’
 void print_integer(int n, int radix, char* prefix);
                                      ~~~~~~^~~~~~

 */

/* 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.