#include <iostream> using namespace std; extern "C" { int My_isupper(int c); } void VerboseUpperTest(char c); void UpperTest(char c, bool result); int main() { VerboseUpperTest('a'); VerboseUpperTest('A'); VerboseUpperTest('z'); VerboseUpperTest('Z'); VerboseUpperTest('0'); VerboseUpperTest('?'); cout << "There should be no error here " << endl; UpperTest('a', false); UpperTest('A', true); cout << " We should get an error here " << endl; UpperTest('a', true); UpperTest('A', false); return 0; } void UpperTest(char c, bool result) { bool functionSays {static_cast<bool>(My_isupper(c))}; if (result) { if (not functionSays) { cout << "error, should be true but is " << static_cast<int>(functionSays) << endl; } } else { if (functionSays) { cout << "error, should be false but is " << static_cast<int>(functionSays) << endl; } } } void VerboseUpperTest(char c){ cout << c << " is "; if(My_isupper(c) == 0) { cout << " NOT "; } cout << " uppercase." << endl; }