Source of test_misc_utilities.cpp


  1: //test_misc_utilities.cpp
  2: //A test driver for some of the simpler facilities of the
  3: //utilities package (free functions and defined constants).

  5: #include <iostream>
  6: #include <iomanip>
  7: using namespace std;

  9: #include "utilities.h"
 10: using Scobey::Pause;
 11: using Scobey::ClearScreen;
 12: using Scobey::isEven;
 13: using Scobey::isOdd;
 14: using Scobey::gcd;
 15: using Scobey::numberOfDigits;
 16: using Scobey::DAYS_OF_THE_WEEK_LONG;
 17: using Scobey::DAYS_OF_THE_WEEK_SHORT;
 18: using Scobey::MONTHS_OF_THE_YEAR_LONG;
 19: using Scobey::MONTHS_OF_THE_YEAR_SHORT;
 20: using Scobey::CARD_DECK;
 21: using Scobey::NAMES_3CHAR;

 23: int main()
 24: {
 25:     cout << "\nTesting the following utilities from the Scobey namepsace:"
 26:         "\nScobey::ClearScreen()"
 27:         "\nScobey::isEven()"
 28:         "\nScobey::isOdd()"
 29:         "\nScobey::gcd()"
 30:         "\nScobey::numberOfDigits()"
 31:         "\nScobey::DAYS_OF_THE_WEEK_LONG"
 32:         "\nScobey::DAYS_OF_THE_WEEK_SHORT"
 33:         "\nScobey::MONTHS_OF_THE_YEAR_LONG"
 34:         "\nScobey::MONTHS_OF_THE_YEAR_SHORT"
 35:         "\nScobey::CARD_DECK"
 36:         "\nScobey::NAMES_3CHAR\n";
 37:     Pause();

 39:     ClearScreen();
 40:     cout << "\nIs 6 even?  Answer: ";
 41:     cout << boolalpha << isEven(6);;
 42:     cout << "\nIs 5 even?  Answer: ";
 43:     cout << boolalpha << isEven(5) << endl;
 44:     Pause();

 46:     cout << "Is 5 odd?  Answer: ";
 47:     cout << boolalpha << isOdd(5);
 48:     cout << "\nIs 6 odd?  Answer: ";
 49:     cout << boolalpha << isOdd(6) << endl;
 50:     Pause();

 52:     ClearScreen();
 53:     cout << "\ngcd of 12 and 30       = " << gcd(12, 30);
 54:     cout << "\ngcd of 17 and 111      = " << gcd(17, 111);
 55:     cout << "\ngcd of 12345 and 54321 = " << gcd(12345, 54321) << endl;
 56:     Pause();

 58:     ClearScreen();
 59:     cout << "\nNumber of digits in 1      = "
 60:         << numberOfDigits(1);
 61:     cout << "\nNumber of digits in 1234   = "
 62:         << numberOfDigits(1234);
 63:     cout << "\nNumber of digits in 246810 = "
 64:         << numberOfDigits(246810) << endl;
 65:     Pause();

 67:     ClearScreen();
 68:     cout << "Here is listing of DAYS_OF_THE_WEEK_LONG:\n";
 69:     for (int i=0; i<7; i++) cout << DAYS_OF_THE_WEEK_LONG[i] << endl;
 70:     Pause();

 72:     ClearScreen();
 73:     cout << "Here is listing of DAYS_OF_THE_WEEK_SHORT:\n";
 74:     for (int i=0; i<7; i++) cout << DAYS_OF_THE_WEEK_SHORT[i] << endl;
 75:     Pause();

 77:     ClearScreen();
 78:     cout << "Here is listing of MONTHS_OF_THE_YEAR_LONG:\n";
 79:     for (int i=0; i<12; i++) cout << MONTHS_OF_THE_YEAR_LONG[i] << endl;
 80:     Pause();

 82:     ClearScreen();
 83:     cout << "Here is listing of MONTHS_OF_THE_YEAR_SHORT:\n";
 84:     for (int i=0; i<12; i++) cout << MONTHS_OF_THE_YEAR_SHORT[i] << endl;
 85:     Pause();

 87:     ClearScreen();
 88:     cout << "Here is listing of CARD_DECK:\n";
 89:     for (int i=0; i<52; i++)
 90:     {
 91:         if ((i+1) % 13 == 0)
 92:             cout << CARD_DECK[i] << " " << endl;
 93:         else
 94:             cout << CARD_DECK[i] << " ";
 95:     }
 96:     Pause();

 98:     ClearScreen();
 99:     cout << "Here is listing of NAMES_3CHAR:\n";
100:     for (int i=0; i<50; i++)
101:     {
102:         if ((i+1) % 10 == 0)
103:             cout << NAMES_3CHAR[i] << " " << endl;
104:         else
105:             cout << NAMES_3CHAR[i] << " ";
106:     }
107:     Pause();

109:     Pause(0, "No more tests to perform."
110:         "\nProgram will now terminate.");
111: }