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 | // This is what HW04 would look like if it were based on HW02 instead of HW05.
#include "print_integer.h" // remember: For HW04, you would have "mintf.h"
int main(int argc, char* argv[]) {
// TEST 00: Empty test
// (nothing)
// Expect: no output
// TEST 01: one particular digit in base 10
print_integer(0, 10, "");
// EXPECT: 0
// TEST 02: any non-negative single-digit number in base 10
print_integer(5, 10, "");
// EXPECT: 5
// TEST 03: … in any base
print_integer(10, 16, "");
// EXPECT: a
// TEST 04: … with multiple digits
print_integer(123, 10, "");
// EXPECT: 123
// TEST 05: … and negative
print_integer(-123, 10, "");
// EXPECT: -123
// TEST 06: … with a single-character prefix
print_integer(-123, 10, "$");
// EXPECT: -$123
// TEST 07: … with a multi-character prefix
print_integer(-123, 10, "$/€");
// EXPECT: -$/€123
return EXIT_SUCCESS;
}
|
© Copyright 2021 Alexander J. Quinn This content is protected and may not be shared, uploaded, or distributed.