home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 February: Tool Chest / Dev.CD Feb 95 / Dev.CD Feb 95.toast / New System Software Extensions / ASLM SDK v1.1.2 / ASLM Examples / TestTools / Sources / SIVTableTest.cp < prev    next >
Encoding:
Text File  |  1994-11-21  |  5.5 KB  |  234 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        SIVTableTest.cp
  3.  
  4.     Contains:    Program to use the test shared classes
  5.  
  6.     Copyright:    © 1992-1993 by Apple Computer, Inc., all rights reserved.
  7.  
  8. */
  9.  
  10. #include <GlobalNew.h>
  11. #ifndef __STDIO__
  12. #include <stdio.h>
  13. #endif
  14. #ifndef __CTYPE__
  15. #include <CType.h>
  16. #endif
  17. #ifndef __LIBRARYMANAGERUTILITIES__
  18. #include <LibraryManagerUtilities.h>
  19. #endif
  20.  
  21. #include "SITestClasses.h"
  22.  
  23. /*******************************************************************************
  24. ** Class TSITest3a
  25. ********************************************************************************/
  26.  
  27. static short    gState    = 0;
  28.  
  29. class TSITest3a : public TSITest3
  30. {
  31.     public:
  32.                         TSITest3a();
  33.         virtual            ~TSITest3a();
  34.         
  35.         virtual int        VTest1(int, int);
  36.         virtual int        VTest2(int, int);
  37.                 
  38.     private:
  39.         int        fField2;
  40. };
  41.  
  42. /*******************************************************************************
  43. ** Class TSITest3a
  44. ********************************************************************************/
  45.  
  46. TSITest3a::TSITest3a()
  47. {
  48.     fField2 = gState++;
  49. }
  50.  
  51. TSITest3a::~TSITest3a()
  52. {
  53.     switch (fField2)
  54.     {
  55.         case 0:
  56.             if (gState++ != fField2 + 3)
  57.                 DoDebugBreak("TSITest3a::~TSITest3a - gState not right");
  58.             break;
  59.             
  60.         default:
  61.             gState += 1;
  62.             DoDebugBreak("TSITest3a::~TSITest3a - fField2 not right");
  63.             break;
  64.     }
  65. }
  66.  
  67. int TSITest3a::VTest1(int a, int b)
  68. {
  69.     switch (fField2)
  70.     {
  71.         case 0:
  72.             if (a != 37 || b != 38)
  73.                 DoDebugBreak("TSiTest3a::VTest1 - arguments incorrect");
  74.             if (gState++ != fField2 + 1)
  75.                 DoDebugBreak("TSiTest3a::VTest1 - gState not right");
  76.             break;
  77.             
  78.         default:
  79.             gState += 1;
  80.             DoDebugBreak("TSITest3a::VTest1 - fField2 not right");
  81.     }
  82.     return TSITest3::VTest1(a, b);
  83. }
  84.  
  85. int TSITest3a::VTest2(int a, int b)
  86. {
  87.     switch (fField2)
  88.     {
  89.         case 0:
  90.             if (a != 39 || b != 40)
  91.                 DoDebugBreak("TSiTest3a::VTest2 - arguments incorrect");
  92.             if (gState++ != fField2 + 2)
  93.                 DoDebugBreak("TSiTest3a::VTest2 - gState not right");
  94.             break;
  95.             
  96.         default:
  97.             gState += 1;
  98.             DoDebugBreak("TSITest3a::VTest2 - fField not right");
  99.             break;
  100.     }
  101.     return TSITest3::VTest2(a, b);
  102. }
  103.  
  104. /*******************************************************************************
  105. ** Main
  106. ********************************************************************************/
  107.  
  108. int main(int argc, char** argv)
  109. {
  110.     int        a, b, c, d, e, f;
  111.     Boolean    doBreak = false;
  112.     short    index;
  113.     
  114.     for (index = 1; index < argc; index++)
  115.     {
  116.         if (argv[index][0] == '-')
  117.         { 
  118.             switch (tolower(argv[index][1]))
  119.             {
  120.                 case 'x':
  121.                     doBreak = true;
  122.                     break;
  123.                     
  124.                 default:
  125.                     fprintf(stderr, "### ERROR: Unknown option - '%s'\n", argv[index]);
  126.                     return 1;
  127.             }
  128.         }
  129.         else
  130.         {
  131.             fprintf(stderr, "### ERROR: Unknown option - '%s'\n", argv[index]);
  132.             return 1;
  133.         }
  134.     }
  135.     
  136.     if (doBreak)
  137.         DoDebugBreak("About to call InitLibraryManager");
  138.  
  139.     InitLibraryManager();
  140.     TRY
  141.         InitTestLibrary();
  142.         {
  143.             TNVTest1* test = new TNVTest1;    // state 0
  144.             a = test->NVTest1(1, 2);        // state 1
  145.             b = test->NVTest2(3, 4);        // state 2
  146.             delete test;                    // state 3
  147.         }
  148.         {
  149.             TNVTest2* test = new TNVTest2;    // state 4 & 5
  150.             a = test->NVTest1(5, 6);        // state 6
  151.             b = test->NVTest2(7, 8);        // state 7
  152.             c = test->NVTest3(9, 10);        // state 8
  153.             d = test->NVTest4(11, 12);        // state 9
  154.             delete test;                    // state 10 & 11
  155.         }
  156.         {
  157.             TSITest1* test = new TSITest1;    // state 12
  158.             a = test->VTest1(13, 14);        // state 13
  159.             b = test->VTest2(15, 16);        // state 14
  160.             c = test->NVTest1(17, 18);        // state 15
  161.             d = test->NVTest2(19, 20);        // state 16
  162.             delete test;                    // state 17
  163.         }
  164.         {
  165.             TSITest2* test = new TSITest2;    // state 18
  166.             a = test->VTest1(21, 22);        // state 19
  167.             b = test->VTest2(23, 24);        // state 20
  168.             c = test->NVTest1(25, 26);        // state 21
  169.             d = test->NVTest2(27, 28);        // state 22
  170.             delete test;                    // state 23
  171.         }
  172.         {
  173.             TSITest3* test = new TSITest3;    // state 24
  174.             a = test->VTest1(29, 30);        // state 25
  175.             b = test->VTest2(31, 32);        // state 26
  176.             c = test->NVTest1(33, 34);        // state 27
  177.             d = test->NVTest2(35, 36);        // state 28
  178.             delete test;                    // state 29
  179.         }
  180.         {
  181.             TSITest3a* test = new TSITest3a;// state 30
  182.             a = test->VTest1(37, 38);        // state 31
  183.             if (gState != 2)
  184.                 DoDebugBreak("Call to TSITest3a::VTest1 did not go locally");
  185.             if (GetStateValue() != 32)
  186.                 DoDebugBreak("Call to TSITest3a::VTest1 did not go to inherited");
  187.             b = test->VTest2(39, 40);        // state 32
  188.             if (gState != 3)
  189.                 DoDebugBreak("Call to TSITest3a::VTest2 did not go locally");
  190.             if (GetStateValue() != 33)
  191.                 DoDebugBreak("Call to TSITest3a::VTest2 did not go to inherited");
  192.             c = test->NVTest1(41, 42);        // state 33
  193.             d = test->NVTest2(43, 44);        // state 34
  194.             delete test;                    // state 35
  195.             if (gState != 4)
  196.                 DoDebugBreak("Call to TSITest3a::~TSITest3a did not go locally");
  197.             if (GetStateValue() != 36)
  198.                 DoDebugBreak("Call to TSITest3a::~TSITest3a did not go to inherited");
  199.         }
  200.         {
  201.             TSITest4* test = new TSITest4;
  202.             a = test->VTest1(4, 2);
  203.             b = test->VTest2(4, 2);
  204.             c = test->VTest3(4, 2);
  205.             d = test->VTest4(4, 2);
  206.             e = test->NVTest1(4, 2);
  207.             f = test->NVTest2(4, 2);
  208.             delete test;
  209.         }
  210.         {
  211.             TSITest5* test = new TSITest5;
  212.             a = test->VTest1(4, 2);
  213.             b = test->VTest2(4, 2);
  214.             c = test->VTest3(4, 2);
  215.             d = test->VTest4(4, 2);
  216.             e = test->NVTest1(4, 2);
  217.             f = test->NVTest2(4, 2);
  218.             delete test;
  219.         }
  220.         {
  221.             TSITest5 test;
  222.             a = test.VTest1(4, 2);
  223.             b = test.VTest2(4, 2);
  224.             c = test.VTest3(4, 2);
  225.             d = test.VTest4(4, 2);
  226.             e = test.NVTest1(4, 2);
  227.             f = test.NVTest2(4, 2);
  228.         }
  229.     CATCH_ALL
  230.         fprintf(stderr, "TestLibrary is not installed!\n");
  231.     ENDTRY
  232.     CleanupLibraryManager();
  233.     return 0;
  234. }