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 / SITestClasses.cp < prev    next >
Encoding:
Text File  |  1994-11-21  |  11.6 KB  |  588 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        SITestClasses.cp
  3.  
  4.     Contains:    Test code for SI-type classes
  5.  
  6.     Copyright:    © 1992-1993 by Apple Computer, Inc., all rights reserved.
  7.  
  8. */
  9.  
  10. #define qDebug 1
  11.  
  12. #include <GlobalNew.h>
  13. #include "SITestClasses.h"
  14.  
  15. #ifndef __LIBRARYMANAGERUTILITIES__
  16. #include <LibraryManagerUtilities.h>
  17. #endif
  18.  
  19. static unsigned short    gState;
  20.  
  21. /*******************************************************************************
  22. ** InitTestLibrary
  23. ********************************************************************************/
  24.  
  25. void InitTestLibrary()
  26. {
  27.     gState = 0;
  28. }
  29.  
  30. unsigned short GetStateValue()
  31. {
  32.     return gState;
  33. }
  34.  
  35. /*******************************************************************************
  36. ** Class TNVTest1
  37. ********************************************************************************/
  38.  
  39. #define knv1state1    0
  40. #define knv1state2    4
  41.  
  42. TNVTest1::TNVTest1()
  43. {
  44.     fField = gState++;
  45.     if (fField != knv1state1 && fField != knv1state2)
  46.         DebugBreak("TNVTest1::TNVTest1 - state not right");
  47. }
  48.  
  49. TNVTest1::~TNVTest1()
  50. {
  51.     switch (fField)
  52.     {
  53.         case knv1state1:
  54.             if (gState++ != fField + 3)
  55.                 DebugBreak("TNVTest1::~TNVTest1 - gState not correct");
  56.             break;
  57.             
  58.         case knv1state2:
  59.             if (gState++ != fField + 7)
  60.                 DebugBreak("TNVTest1::~TNVTest1 - gState not correct");
  61.             break;
  62.             
  63.         default:
  64.             gState += 1;
  65.             DebugBreak("TNVTest1::~TNVTest1 - fField not correct");
  66.     }
  67. }
  68.  
  69.  
  70. int TNVTest1::NVTest1(int a, int b)
  71. {
  72.     switch (fField)
  73.     {
  74.         case knv1state1:
  75.             if (a != 1 || b != 2)
  76.                 DebugBreak("TNVTest1::NVTest1 - arguments incorrect");
  77.             if (gState++ != fField + 1)
  78.                 DebugBreak("TNVTest1::NVTest1 - gState not right");
  79.             break;
  80.             
  81.         case knv1state2:
  82.             if (a != 5 || b != 6)
  83.                 DebugBreak("TNVTest1::NVTest1 - arguments incorrect");
  84.             if (gState++ != fField + 2)
  85.                 DebugBreak("TNVTest1::NVTest1 - gState not right");
  86.             break;
  87.             
  88.         default:
  89.             gState += 1;
  90.             DebugBreak("TNVTest1::NVTest1 - fField not right");
  91.     }
  92.     return a + b;
  93. }
  94.  
  95. int TNVTest1::NVTest2(int a, int b)
  96. {
  97.     switch (fField)
  98.     {
  99.         case knv1state1:
  100.             if (a != 3 || b != 4)
  101.                 DebugBreak("TNVTest1::NVTest2 - arguments incorrect");
  102.             if (gState++ != fField + 2)
  103.                 DebugBreak("TNVTest1::NVTest2 - gState not right");
  104.             break;
  105.             
  106.         case knv1state2:
  107.             if (a != 7 || b != 8)
  108.                 DebugBreak("TNVTest1::NVTest2 - arguments incorrect");
  109.             if (gState++ != fField + 3)
  110.                 DebugBreak("TNVTest1::NVTest2 - gState not right");
  111.             break;
  112.             
  113.         default:
  114.             gState += 1;
  115.             DebugBreak("TNVTest1::NVTest1 - fField not right");
  116.     }
  117.     return a - b;
  118. }
  119.  
  120. /*******************************************************************************
  121. ** Class TNVTest2
  122. ********************************************************************************/
  123.  
  124. #define knv2state    5
  125.  
  126. TNVTest2::TNVTest2()
  127. {
  128.     fField2 = gState++;
  129.     if (fField2 != knv2state)
  130.         DebugBreak("TNVTest2::TNVTest2 - state not right");
  131. }
  132.  
  133. TNVTest2::~TNVTest2()
  134. {
  135.     if (fField2 != knv2state)
  136.         DebugBreak("TNVTest2::~TNVTest2 - fField2 not right");
  137.     if (gState++ != fField2 + 5)
  138.         DebugBreak("TNVTest2::~TNVTest2 - state not right");
  139. }
  140.  
  141.  
  142. int TNVTest2::NVTest3(int a, int b)
  143. {
  144.     if (gState++ != knv2state + 3)
  145.         DebugBreak("TNVTest2::NVTest3 - state not right");
  146.     if (fField2 != knv2state)
  147.         DebugBreak("TNVTest2::NVTest3 - fField2 not right");
  148.     return a + b;
  149. }
  150.  
  151. int TNVTest2::NVTest4(int a, int b)
  152. {
  153.     if (gState++ != knv2state + 4)
  154.         DebugBreak("TNVTest2::NVTest4 - state not right");
  155.     if (fField2 != knv2state)
  156.         DebugBreak("TNVTest2::NVTest4 - fField2 not right");
  157.     return a + b;
  158. }
  159.  
  160. /*******************************************************************************
  161. ** Class TSITest1
  162. ********************************************************************************/
  163.  
  164. #define ksi1state1    12
  165.  
  166. TSITest1::TSITest1()
  167. {
  168.     fField = gState++;
  169.     if (fField != ksi1state1)
  170.         DebugBreak("TSITest1::TSITest1 - state not right");
  171. }
  172.  
  173. TSITest1::~TSITest1()
  174. {
  175.     switch (fField)
  176.     {
  177.         case ksi1state1:
  178.             if (gState++ != fField + 5)
  179.                 DebugBreak("TSITest1::~TSITest1 - gState not correct");
  180.             break;
  181.             
  182.         default:
  183.             gState += 1;
  184.             DebugBreak("TSITest1::~TSITest1 - fField not correct");
  185.             break;
  186.     }
  187. }
  188.  
  189. int TSITest1::VTest1(int a, int b)
  190. {
  191.     switch (fField)
  192.     {
  193.         case ksi1state1:
  194.             if (a != 13 || b != 14)
  195.                 DebugBreak("TSITest1::VTest1 - arguments incorrect");
  196.             if (gState++ != fField + 1)
  197.                 DebugBreak("TSITest1::VTest1 - gState not right");
  198.             break;
  199.             
  200.         default:
  201.             gState += 1;
  202.             DebugBreak("TSITest1::VTest1 - fField not right");
  203.             break;
  204.     }
  205.     return a + b;
  206. }
  207.  
  208. int TSITest1::VTest2(int a, int b)
  209. {
  210.     switch (fField)
  211.     {
  212.         case ksi1state1:
  213.             if (a != 15 || b != 16)
  214.                 DebugBreak("TSITest1::VTest2 - arguments incorrect");
  215.             if (gState++ != fField + 2)
  216.                 DebugBreak("TSITest1::VTest2 - gState not right");
  217.             break;
  218.             
  219.         default:
  220.             gState += 1;
  221.             DebugBreak("TSITest1::VTest2 - fField not right");
  222.             break;
  223.     }
  224.     return a - b;
  225. }
  226.  
  227. int TSITest1::NVTest1(int a, int b)
  228. {
  229.     switch (fField)
  230.     {
  231.         case ksi1state1:
  232.             if (a != 17 || b != 18)
  233.                 DebugBreak("TSITest1::NVTest1 - arguments incorrect");
  234.             if (gState++ != fField + 3)
  235.                 DebugBreak("TSITest1::NVTest1 - gState not right");
  236.             break;
  237.             
  238.         default:
  239.             gState += 1;
  240.             DebugBreak("TSITest1::NVTest1 - fField not right");
  241.             break;
  242.     }
  243.     return a + b;
  244. }
  245.  
  246. int TSITest1::NVTest2(int a, int b)
  247. {
  248.     switch (fField)
  249.     {
  250.         case ksi1state1:
  251.             if (a != 19 || b != 20)
  252.                 DebugBreak("TSITest1::NVTest2 - arguments incorrect");
  253.             if (gState++ != fField + 4)
  254.                 DebugBreak("TSITest1::NVTest2 - gState not right");
  255.             break;
  256.             
  257.         default:
  258.             gState += 1;
  259.             DebugBreak("TSITest1::NVTest2 - fField not right");
  260.             break;
  261.     }
  262.     return a - b;
  263. }
  264.  
  265. /*******************************************************************************
  266. ** Class TSITest2
  267. ********************************************************************************/
  268.  
  269. #define ksi2state1    18
  270.  
  271. TSITest2::TSITest2()
  272. {
  273.     fField = gState++;
  274.     if (fField != ksi2state1)
  275.         DebugBreak("TSITest2::TSITest2 - state not right");
  276. }
  277.  
  278. TSITest2::~TSITest2()
  279. {
  280.     switch (fField)
  281.     {
  282.         case ksi2state1:
  283.             if (gState++ != fField + 5)
  284.                 DebugBreak("TSITest2::~TSITest2 - gState not correct");
  285.             break;
  286.             
  287.         default:
  288.             gState += 1;
  289.             DebugBreak("TSITest2::~TSITest2 - fField not correct");
  290.             break;
  291.     }
  292. }
  293.  
  294. int TSITest2::VTest1(int a, int b)
  295. {
  296.     switch (fField)
  297.     {
  298.         case ksi2state1:
  299.             if (a != 21 || b != 22)
  300.                 DebugBreak("TSITest2::VTest1 - arguments incorrect");
  301.             if (gState++ != fField + 1)
  302.                 DebugBreak("TSITest2::VTest1 - gState not right");
  303.             break;
  304.             
  305.         default:
  306.             gState += 1;
  307.             DebugBreak("TSITest2::VTest1 - fField not right");
  308.             break;
  309.     }
  310.     return a + b;
  311. }
  312.  
  313. int TSITest2::VTest2(int a, int b)
  314. {
  315.     switch (fField)
  316.     {
  317.         case ksi2state1:
  318.             if (a != 23 || b != 24)
  319.                 DebugBreak("TSITest2::VTest2 - arguments incorrect");
  320.             if (gState++ != fField + 2)
  321.                 DebugBreak("TSITest2::VTest2 - gState not right");
  322.             break;
  323.             
  324.         default:
  325.             gState += 1;
  326.             DebugBreak("TSITest2::VTest2 - fField not right");
  327.             break;
  328.     }
  329.     return a - b;
  330. }
  331.  
  332. int TSITest2::NVTest1(int a, int b)
  333. {
  334.     switch (fField)
  335.     {
  336.         case ksi2state1:
  337.             if (a != 25 || b != 26)
  338.                 DebugBreak("TSITest2::NVTest1 - arguments incorrect");
  339.             if (gState++ != fField + 3)
  340.                 DebugBreak("TSITest2::NVTest1 - gState not right");
  341.             break;
  342.             
  343.         default:
  344.             gState += 1;
  345.             DebugBreak("TSITest2::NVTest1 - fField not right");
  346.             break;
  347.     }
  348.     return a + b;
  349. }
  350.  
  351. int TSITest2::NVTest2(int a, int b)
  352. {
  353.     switch (fField)
  354.     {
  355.         case ksi2state1:
  356.             if (a != 27 || b != 28)
  357.                 DebugBreak("TSITest2::NVTest2 - arguments incorrect");
  358.             if (gState++ != fField + 4)
  359.                 DebugBreak("TSITest2::NVTest2 - gState not right");
  360.             break;
  361.             
  362.         default:
  363.             gState += 1;
  364.             DebugBreak("TSITest2::NVTest2 - fField not right");
  365.             break;
  366.     }
  367.     return a - b;
  368. }
  369.  
  370. /*******************************************************************************
  371. ** Class TSITest3
  372. ********************************************************************************/
  373.  
  374. #define ksi3state1    24
  375. #define ksi3state2    30
  376.  
  377. TSITest3::TSITest3()
  378. {
  379.     fField = gState++;
  380.     if (fField != ksi3state1 && fField != ksi3state2)
  381.         DebugBreak("TSITest3::TSITest3 - state not right");
  382. }
  383.  
  384. TSITest3::~TSITest3()
  385. {
  386.     switch (fField)
  387.     {
  388.         case ksi3state1:
  389.             if (gState++ != fField + 5)
  390.                 DebugBreak("TSITest3::~TSITest3 - gState not correct");
  391.             break;
  392.             
  393.         case ksi3state2:
  394.             if (gState++ != fField + 5)
  395.                 DebugBreak("TSITest3::~TSITest3 - gState not correct");
  396.             break;
  397.             
  398.         default:
  399.             gState += 1;
  400.             DebugBreak("TSITest3::~TSITest3 - fField not correct");
  401.             break;
  402.     }
  403. }
  404.  
  405. int TSITest3::VTest1(int a, int b)
  406. {
  407.     switch (fField)
  408.     {
  409.         case ksi3state1:
  410.             if (a != 29 || b != 30)
  411.                 DebugBreak("TSITest3::VTest1 - arguments incorrect");
  412.             if (gState++ != fField + 1)
  413.                 DebugBreak("TSITest3::VTest1 - gState not right");
  414.             break;
  415.             
  416.         case ksi3state2:
  417.             if (a != 37 || b != 38)
  418.                 DebugBreak("TSITest3::VTest1 - arguments incorrect");
  419.             if (gState++ != fField + 1)
  420.                 DebugBreak("TSITest3::VTest1 - gState not right");
  421.             break;
  422.             
  423.         default:
  424.             gState += 1;
  425.             DebugBreak("TSITest3::VTest1 - fField not right");
  426.             break;
  427.     }
  428.     return a + b;
  429. }
  430.  
  431. int TSITest3::VTest2(int a, int b)
  432. {
  433.     switch (fField)
  434.     {
  435.         case ksi3state1:
  436.             if (a != 31 || b != 32)
  437.                 DebugBreak("TSITest3::VTest2 - arguments incorrect");
  438.             if (gState++ != fField + 2)
  439.                 DebugBreak("TSITest3::VTest2 - gState not right");
  440.             break;
  441.             
  442.         case ksi3state2:
  443.             if (a != 39 || b != 40)
  444.                 DebugBreak("TSITest3::VTest1 - arguments incorrect");
  445.             if (gState++ != fField + 2)
  446.                 DebugBreak("TSITest3::VTest1 - gState not right");
  447.             break;
  448.             
  449.         default:
  450.             gState += 1;
  451.             DebugBreak("TSITest3::VTest2 - fField not right");
  452.             break;
  453.     }
  454.     return a - b;
  455. }
  456.  
  457. int TSITest3::NVTest1(int a, int b)
  458. {
  459.     switch (fField)
  460.     {
  461.         case ksi3state1:
  462.             if (a != 33 || b != 34)
  463.                 DebugBreak("TSITest3::NVTest1 - arguments incorrect");
  464.             if (gState++ != fField + 3)
  465.                 DebugBreak("TSITest3::NVTest1 - gState not right");
  466.             break;
  467.             
  468.         case ksi3state2:
  469.             if (a != 41 || b != 42)
  470.                 DebugBreak("TSITest3::NVTest1 - arguments incorrect");
  471.             if (gState++ != fField + 3)
  472.                 DebugBreak("TSITest3::NVTest1 - gState not right");
  473.             break;
  474.             
  475.         default:
  476.             gState += 1;
  477.             DebugBreak("TSITest3::NVTest1 - fField not right");
  478.             break;
  479.     }
  480.     return a + b;
  481. }
  482.  
  483. int TSITest3::NVTest2(int a, int b)
  484. {
  485.     switch (fField)
  486.     {
  487.         case ksi3state1:
  488.             if (a != 35 || b != 36)
  489.                 DebugBreak("TSITest3::NVTest2 - arguments incorrect");
  490.             if (gState++ != fField + 4)
  491.                 DebugBreak("TSITest3::NVTest2 - gState not right");
  492.             break;
  493.             
  494.         case ksi3state2:
  495.             if (a != 43 || b != 44)
  496.                 DebugBreak("TSITest3::NVTest2 - arguments incorrect");
  497.             if (gState++ != fField + 4)
  498.                 DebugBreak("TSITest3::NVTest2 - gState not right");
  499.             break;
  500.             
  501.         default:
  502.             gState += 1;
  503.             DebugBreak("TSITest3::NVTest2 - fField not right");
  504.             break;
  505.     }
  506.     return a - b;
  507. }
  508.  
  509. /*******************************************************************************
  510. ** Class TSITest4
  511. ********************************************************************************/
  512.  
  513. TSITest4::TSITest4()
  514. {
  515.     fField = 0;
  516. }
  517.  
  518. TSITest4::~TSITest4()
  519. {}
  520.  
  521. int TSITest4::VTest1(int a, int b)
  522. {
  523.     return a + b;
  524. }
  525.  
  526. int TSITest4::VTest2(int a, int b)
  527. {
  528.     return a - b;
  529. }
  530.  
  531. int TSITest4::VTest3(int a, int b)
  532. {
  533.     return a + b;
  534. }
  535.  
  536. int TSITest4::VTest4(int a, int b)
  537. {
  538.     return a - b;
  539. }
  540.  
  541. int TSITest4::NVTest1(int a, int b)
  542. {
  543.     return a + b;
  544. }
  545.  
  546. int TSITest4::NVTest2(int a, int b)
  547. {
  548.     return a - b;
  549. }
  550.  
  551. /*******************************************************************************
  552. ** Class TSITest5
  553. ********************************************************************************/
  554.  
  555. TSITest5::TSITest5()
  556. {
  557.     fField2 = 0;
  558. }
  559.  
  560. TSITest5::~TSITest5()
  561. {}
  562.  
  563. int TSITest5::VTest1(int a, int b)
  564. {
  565.     return a - b;
  566. }
  567.  
  568. int TSITest5::VTest2(int a, int b)
  569. {
  570.     return a + b;
  571. }
  572.  
  573. int TSITest5::VTest4(int a, int b)
  574. {
  575.     return a - b;
  576. }
  577.  
  578. int TSITest5::NVTest1(int a, int b)
  579. {
  580.     return a + b;
  581. }
  582.  
  583. int TSITest5::NVTest2(int a, int b)
  584. {
  585.     return a - b;
  586. }
  587.  
  588.