File indexing completed on 2025-10-12 04:59:54

0001 // bjgb_dealercount.t.cpp                                             -*-C++-*-
0002 #include <bjgb_dealercount.h>
0003 
0004 #include <cstdlib>
0005 #include <iostream>
0006 #include <sstream>
0007 
0008 // ============================================================================
0009 //                        STANDARD ASSERT TEST FUNCTION
0010 // ----------------------------------------------------------------------------
0011 
0012 namespace {
0013 
0014 int testStatus = 0;
0015 
0016 void aSsErT(bool condition, const char *message, int line)
0017 {
0018     if (condition) {
0019         std::cout << "Error " __FILE__ "(" << line << "): " << message << "    (failed)" << std::endl;
0020 
0021         if (0 <= testStatus && testStatus <= 100) {
0022             ++testStatus;
0023         }
0024     }
0025 }
0026 
0027 } // namespace
0028 
0029 // ============================================================================
0030 //                         STANDARD TEST DRIVER MACROS
0031 // ----------------------------------------------------------------------------
0032 
0033 #define ASSERT(X) aSsErT(!(X), #X, __LINE__);
0034 
0035 // ============================================================================
0036 //                        GLOBAL TYPEDEFS FOR TESTING
0037 // ----------------------------------------------------------------------------
0038 
0039 typedef bjgb::DealerCount::Enum Enum;
0040 typedef bjgb::DealerCount Util;
0041 
0042 // ============================================================================
0043 //                              MAIN PROGRAM
0044 // ----------------------------------------------------------------------------
0045 
0046 int main(int argc, char *argv[])
0047 {
0048     const int test = argc > 1 ? std::atoi(argv[1]) : 0;
0049     const bool verbose = argc > 2;
0050     const bool veryVerbose = argc > 3;
0051     const bool veryVeryVerbose = argc > 4;
0052     const bool veryVeryVeryVerbose = argc > 5;
0053 
0054     std::cout << "TEST " << __FILE__ << " CASE " << test << std::endl;
0055 
0056     switch (test) {
0057     case 0:
0058     case 1: {
0059         // --------------------------------------------------------------------
0060         // BREATHING TEST
0061         //
0062         // Concerns:
0063         //: 1 TBD
0064         //
0065         // Plan:
0066         //: 1 TBD
0067         //
0068         // Testing:
0069         //   BREATHING TEST
0070         // --------------------------------------------------------------------
0071 
0072         if (verbose)
0073             std::cout << std::endl << "BREATHING TEST" << std::endl << "==============" << std::endl;
0074 
0075         // starting from 0, the enumerators are sequential in value
0076         {
0077             int value = 0;
0078 
0079             ASSERT(value++ == Util::e_C17);
0080             ASSERT(value++ == Util::e_C18);
0081             ASSERT(value++ == Util::e_C19);
0082             ASSERT(value++ == Util::e_C20);
0083             ASSERT(value++ == Util::e_C21);
0084             ASSERT(value++ == Util::e_CBJ);
0085             ASSERT(value++ == Util::e_COV);
0086 
0087             ASSERT(value == Util::k_NUM_FINAL_COUNTS);
0088         }
0089 
0090         // sanity check limits of 'fini'
0091         {
0092             ASSERT(Util::e_C17 == Util::fini(17));
0093             ASSERT(Util::e_C21 == Util::fini(21));
0094         }
0095 
0096     } break;
0097     default: {
0098         std::cerr << "WARNING: CASE `" << test << "' NOT FOUND." << std::endl;
0099         testStatus = -1;
0100     }
0101     }
0102 
0103     if (testStatus > 0) {
0104         std::cerr << "Error, non-zero test status = " << testStatus << "." << std::endl;
0105     }
0106 
0107     return testStatus;
0108 }