
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int printableCount(char S[], int n) ; 

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

    char C[] = "\n I see three bad chars \t, \x7F, and \xFF.~\n" ;
    int cLen = strlen(C) ;
    int lowBound[] =  { 1,  0, 0,  0,  0,      0,      0} ;
    int numChars[] =  {10, 10, 0, 25, 30, cLen-3,   cLen} ;
    int goodChars[] = {10,  9, 0, 23, 27, cLen-7, cLen-5} ;
    /*
        Case 0))  All are printable
        Case 1)  First is not printable
        Case 2)  Zero length
        Case 3)  First and last are not printable
        Case 4)  Check handling of \x7F, one above ~
        Case 5)  Checking end of range
        Case 6)  Check entire string
     */
    for (int i=0; i<sizeof(lowBound)/sizeof(int); ++i) {
        int retV = printableCount(C+lowBound[i], numChars[i]) ;
        printf("Case %d: returned %2d, expected %2d\n", i, retV, goodChars[i]) ;
    }
    /*
        If length is zero, what happens when array points to bad memory.
    */
    int retV = printableCount((char *)NULL, 0) ;
    printf("\nReturned with NULL array: %d\n", retV) ;
    return (EXIT_SUCCESS);
}
