#include #include #include #include "trim.h" const char* cases[] = { // Normal equivalence classes /* 1 */ "No left. No inside. No right.", /* 2 */ "No left. No inside. Right ", /* 3 */ "No left. Inside white space. No right.", /* 4 */ "No left. Inside white space. Right ", /* 5 */ " Left. No inside. No right.", /* 6 */ " Left. No inside. Right ", /* 7 */ " Left. Inside white space. No right.", /* 8 */ " Left. Inside white space. Right ", // Boundary cases /* 9 */ "", // empty string /* 10 */ " \t \n \t", // only whitespace /* 11 */ "NoWhitespace", /* 12 */ "OnlyAWord1\t\t\t\t", /* 13 */ "\t\t\t\t\t\t\tOnlyAWord2", /* 14 */ "\t\t\t\tOnlyAWord3\t\t\t\t" }; const char* results[] = { /* L I R */ /* 1 */ /* 0 0 0 */ "No left. No inside. No right.", /* 0 0 1 */ "No left. No inside. No right.", /* 0 1 0 */ "No left. No inside. No right.", /* 0 1 1 */ "No left. No inside. No right.", /* 1 0 0 */ "No left. No inside. No right.", /* 1 0 1 */ "No left. No inside. No right.", /* 1 1 0 */ "No left. No inside. No right.", /* 1 1 1 */ "No left. No inside. No right.", /* 2 */ /* 0 0 0 */ "No left. No inside. Right ", /* 0 0 1 */ "No left. No inside. Right", /* 0 1 0 */ "No left. No inside. Right ", /* 0 1 1 */ "No left. No inside. Right", /* 1 0 0 */ "No left. No inside. Right ", /* 1 0 1 */ "No left. No inside. Right", /* 1 1 0 */ "No left. No inside. Right ", /* 1 1 1 */ "No left. No inside. Right", /* 3 */ /* 0 0 0 */ "No left. Inside white space. No right.", /* 0 0 1 */ "No left. Inside white space. No right.", /* 0 1 0 */ "No left. Inside white space. No right.", /* 0 1 1 */ "No left. Inside white space. No right.", /* 1 0 0 */ "No left. Inside white space. No right.", /* 1 0 1 */ "No left. Inside white space. No right.", /* 1 1 0 */ "No left. Inside white space. No right.", /* 1 1 1 */ "No left. Inside white space. No right.", /* 4 */ /* 0 0 0 */ "No left. Inside white space. Right ", /* 0 0 1 */ "No left. Inside white space. Right", /* 0 1 0 */ "No left. Inside white space. Right ", /* 0 1 1 */ "No left. Inside white space. Right", /* 1 0 0 */ "No left. Inside white space. Right ", /* 1 0 1 */ "No left. Inside white space. Right", /* 1 1 0 */ "No left. Inside white space. Right ", /* 1 1 1 */ "No left. Inside white space. Right", /* 5 */ /* 0 0 0 */ " Left. No inside. No right.", /* 0 0 1 */ " Left. No inside. No right.", /* 0 1 0 */ " Left. No inside. No right.", /* 0 1 1 */ " Left. No inside. No right.", /* 1 0 0 */ "Left. No inside. No right.", /* 1 0 1 */ "Left. No inside. No right.", /* 1 1 0 */ "Left. No inside. No right.", /* 1 1 1 */ "Left. No inside. No right.", /* 6 */ /* 0 0 0 */ " Left. No inside. Right ", /* 0 0 1 */ " Left. No inside. Right", /* 0 1 0 */ " Left. No inside. Right ", /* 0 1 1 */ " Left. No inside. Right", /* 1 0 0 */ "Left. No inside. Right ", /* 1 0 1 */ "Left. No inside. Right", /* 1 1 0 */ "Left. No inside. Right ", /* 1 1 1 */ "Left. No inside. Right", /* 7 */ /* 0 0 0 */ " Left. Inside white space. No right.", /* 0 0 1 */ " Left. Inside white space. No right.", /* 0 1 0 */ " Left. Inside white space. No right.", /* 0 1 1 */ " Left. Inside white space. No right.", /* 1 0 0 */ "Left. Inside white space. No right.", /* 1 0 1 */ "Left. Inside white space. No right.", /* 1 1 0 */ "Left. Inside white space. No right.", /* 1 1 1 */ "Left. Inside white space. No right.", /* 8 */ /* 0 0 0 */ " Left. Inside white space. Right ", /* 0 0 1 */ " Left. Inside white space. Right", /* 0 1 0 */ " Left. Inside white space. Right ", /* 0 1 1 */ " Left. Inside white space. Right", /* 1 0 0 */ "Left. Inside white space. Right ", /* 1 0 1 */ "Left. Inside white space. Right", /* 1 1 0 */ "Left. Inside white space. Right ", /* 1 1 1 */ "Left. Inside white space. Right", /* 9 */ /* 0 0 0 */ "", /* 0 0 1 */ "", /* 0 1 0 */ "", /* 0 1 1 */ "", /* 1 0 0 */ "", /* 1 0 1 */ "", /* 1 1 0 */ "", /* 1 1 1 */ "", /* 10 */ /* 0 0 0 */ " \t \n \t", /* 0 0 1 */ "", /* 0 1 0 */ " \t \n \t", /* 0 1 1 */ "", /* 1 0 0 */ "", /* 1 0 1 */ "", /* 1 1 0 */ "", /* 1 1 1 */ "", /* 11 */ /* 0 0 0 */ "NoWhitespace", /* 0 0 1 */ "NoWhitespace", /* 0 1 0 */ "NoWhitespace", /* 0 1 1 */ "NoWhitespace", /* 1 0 0 */ "NoWhitespace", /* 1 0 1 */ "NoWhitespace", /* 1 1 0 */ "NoWhitespace", /* 1 1 1 */ "NoWhitespace", /* 12 */ /* 0 0 0 */ "OnlyAWord1\t\t\t\t", /* 0 0 1 */ "OnlyAWord1", /* 0 1 0 */ "OnlyAWord1\t\t\t\t", /* 0 1 1 */ "OnlyAWord1", /* 1 0 0 */ "OnlyAWord1\t\t\t\t", /* 1 0 1 */ "OnlyAWord1", /* 1 1 0 */ "OnlyAWord1\t\t\t\t", /* 1 1 1 */ "OnlyAWord1", /* 13 */ /* 0 0 0 */ "\t\t\t\t\t\t\tOnlyAWord2", /* 0 0 1 */ "\t\t\t\t\t\t\tOnlyAWord2", /* 0 1 0 */ "\t\t\t\t\t\t\tOnlyAWord2", /* 0 1 1 */ "\t\t\t\t\t\t\tOnlyAWord2", /* 1 0 0 */ "OnlyAWord2", /* 1 0 1 */ "OnlyAWord2", /* 1 1 0 */ "OnlyAWord2", /* 1 1 1 */ "OnlyAWord2", /* 14 */ /* 0 0 0 */ "\t\t\t\tOnlyAWord3\t\t\t\t", /* 0 0 1 */ "\t\t\t\tOnlyAWord3", /* 0 1 0 */ "\t\t\t\tOnlyAWord3\t\t\t\t", /* 0 1 1 */ "\t\t\t\tOnlyAWord3", /* 1 0 0 */ "OnlyAWord3\t\t\t\t", /* 1 0 1 */ "OnlyAWord3", /* 1 1 0 */ "OnlyAWord3\t\t\t\t", /* 1 1 1 */ "OnlyAWord3" }; #define sizeof_carray(carray) (sizeof(carray)/sizeof(carray[0])) int main() { size_t i = 0; for ( ; i < sizeof_carray(cases); ++i) { char* dup = strdup( cases[i] ); if ( strcmp(trimRight(dup), results[i * 8 + 1]) != 0 ) fprintf(stderr, "%lu. 0 0 1 [%s] => {%s}\n", i + 1, results[i * 8 + 1], dup ); free(dup); dup = strdup( cases[i] ); if ( strcmp(trimInside(dup), results[i * 8 + 2]) != 0 ) fprintf(stderr, "%lu. 0 1 0 [%s] => {%s}\n", i + 1, results[i * 8 + 2], dup ); free(dup); dup = strdup( cases[i] ); if ( strcmp(trimInside(trimRight(dup)), results[i * 8 + 3]) != 0 ) fprintf(stderr, "%lu. 0 1 1 [%s] => {%s}\n", i + 1, results[i * 8 + 3], dup ); free(dup); dup = strdup( cases[i] ); if ( strcmp(trimLeft(dup), results[i * 8 + 4]) != 0 ) fprintf(stderr, "%lu. 1 0 0 [%s] => {%s}\n", i + 1, results[i * 8 + 4], dup ); free(dup); dup = strdup( cases[i] ); if ( strcmp(trimLeft(trimRight(dup)), results[i * 8 + 5]) != 0 ) fprintf(stderr, "%lu. 1 0 1 [%s] => {%s}\n", i + 1, results[i * 8 + 5], dup ); free(dup); dup = strdup( cases[i] ); if ( strcmp(trimLeft(trimInside(dup)), results[i * 8 + 6]) != 0 ) fprintf(stderr, "%lu. 1 1 0 [%s] => {%s}\n", i + 1, results[i * 8 + 6], dup ); free(dup); dup = strdup( cases[i] ); if ( strcmp(trimLeft(trimInside(trimRight(dup))), results[i * 8 + 7]) != 0 ) fprintf(stderr, "%lu. 1 1 1 [%s] => {%s}\n", i + 1, results[i * 8 + 7], dup ); free(dup); } // Done return 0; }