home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-11-19 | 5.8 KB | 243 lines | [TEXT/MPS ] |
- /*
- File: SIVTableTest.cp
-
- Contains: Program to use the test shared classes
-
- Copyright: © 1992-1994 by Apple Computer, Inc., all rights reserved.
-
- */
-
- #include <GlobalNew.h>
- #ifndef __STDIO__
- #include <stdio.h>
- #endif
- #ifndef __CTYPE__
- #include <ctype.h>
- #endif
- #ifndef __LIBRARYMANAGERUTILITIES__
- #include <LibraryManagerUtilities.h>
- #endif
-
- #include "SITestClasses.h"
-
- /*******************************************************************************
- ** Class TSITest3a
- ********************************************************************************/
-
- static short gState = 0;
-
- class TSITest3a : public TSITest3
- {
- public:
- _CDECL TSITest3a();
- virtual ~_CDECL TSITest3a();
-
- virtual int _CDECL VTest1(int, int);
- virtual int _CDECL VTest2(int, int);
-
- private:
- int fField2;
- };
-
- /*******************************************************************************
- ** Class TSITest3a
- ********************************************************************************/
-
- //
- // This is needed because we inherit from TSITest3 (which declares DummyVirtualFunction)
- // but we don't export our subclass. Since we don't export it, our vtable will make
- // a reference to the inherited DummyVirtualFunction method so we need to
- // define it here or our link will fail.
- //
- ASLM_SCDECLARATION(TSITest3);
-
- TSITest3a::TSITest3a()
- {
- fField2 = gState++;
- }
-
- TSITest3a::~TSITest3a()
- {
- switch (fField2)
- {
- case 0:
- if (gState++ != fField2 + 3)
- DoDebugBreak("TSITest3a::~TSITest3a - gState not right");
- break;
-
- default:
- gState += 1;
- DoDebugBreak("TSITest3a::~TSITest3a - fField2 not right");
- break;
- }
- }
-
- int TSITest3a::VTest1(int a, int b)
- {
- switch (fField2)
- {
- case 0:
- if (a != 37 || b != 38)
- DoDebugBreak("TSiTest3a::VTest1 - arguments incorrect");
- if (gState++ != fField2 + 1)
- DoDebugBreak("TSiTest3a::VTest1 - gState not right");
- break;
-
- default:
- gState += 1;
- DoDebugBreak("TSITest3a::VTest1 - fField2 not right");
- }
- return TSITest3::VTest1(a, b);
- }
-
- int TSITest3a::VTest2(int a, int b)
- {
- switch (fField2)
- {
- case 0:
- if (a != 39 || b != 40)
- DoDebugBreak("TSiTest3a::VTest2 - arguments incorrect");
- if (gState++ != fField2 + 2)
- DoDebugBreak("TSiTest3a::VTest2 - gState not right");
- break;
-
- default:
- gState += 1;
- DoDebugBreak("TSITest3a::VTest2 - fField not right");
- break;
- }
- return TSITest3::VTest2(a, b);
- }
-
- /*******************************************************************************
- ** Main
- ********************************************************************************/
-
- int main(int argc, char** argv)
- {
- int a, b, c, d, e, f;
- Boolean doBreak = false;
- short index;
-
- for (index = 1; index < argc; index++)
- {
- if (argv[index][0] == '-')
- {
- switch (tolower(argv[index][1]))
- {
- case 'x':
- doBreak = true;
- break;
-
- default:
- fprintf(stderr, "### ERROR: Unknown option - '%s'\n", argv[index]);
- return 1;
- }
- }
- else
- {
- fprintf(stderr, "### ERROR: Unknown option - '%s'\n", argv[index]);
- return 1;
- }
- }
-
- if (doBreak)
- DoDebugBreak("About to call InitLibraryManager");
-
- InitLibraryManager();
- TRY
- InitTestLibrary();
- {
- TNVTest1* test = new TNVTest1; // state 0
- a = test->NVTest1(1, 2); // state 1
- b = test->NVTest2(3, 4); // state 2
- delete test; // state 3
- }
- {
- TNVTest2* test = new TNVTest2; // state 4 & 5
- a = test->NVTest1(5, 6); // state 6
- b = test->NVTest2(7, 8); // state 7
- c = test->NVTest3(9, 10); // state 8
- d = test->NVTest4(11, 12); // state 9
- delete test; // state 10 & 11
- }
- {
- TSITest1* test = new TSITest1; // state 12
- a = test->VTest1(13, 14); // state 13
- b = test->VTest2(15, 16); // state 14
- c = test->NVTest1(17, 18); // state 15
- d = test->NVTest2(19, 20); // state 16
- delete test; // state 17
- }
- {
- TSITest2* test = new TSITest2; // state 18
- a = test->VTest1(21, 22); // state 19
- b = test->VTest2(23, 24); // state 20
- c = test->NVTest1(25, 26); // state 21
- d = test->NVTest2(27, 28); // state 22
- delete test; // state 23
- }
- {
- TSITest3* test = new TSITest3; // state 24
- a = test->VTest1(29, 30); // state 25
- b = test->VTest2(31, 32); // state 26
- c = test->NVTest1(33, 34); // state 27
- d = test->NVTest2(35, 36); // state 28
- delete test; // state 29
- }
- {
- TSITest3a* test = new TSITest3a;// state 30
- a = test->VTest1(37, 38); // state 31
- if (gState != 2)
- DoDebugBreak("Call to TSITest3a::VTest1 did not go locally");
- if (GetStateValue() != 32)
- DoDebugBreak("Call to TSITest3a::VTest1 did not go to inherited");
- b = test->VTest2(39, 40); // state 32
- if (gState != 3)
- DoDebugBreak("Call to TSITest3a::VTest2 did not go locally");
- if (GetStateValue() != 33)
- DoDebugBreak("Call to TSITest3a::VTest2 did not go to inherited");
- c = test->NVTest1(41, 42); // state 33
- d = test->NVTest2(43, 44); // state 34
- delete test; // state 35
- if (gState != 4)
- DoDebugBreak("Call to TSITest3a::~TSITest3a did not go locally");
- if (GetStateValue() != 36)
- DoDebugBreak("Call to TSITest3a::~TSITest3a did not go to inherited");
- }
- {
- TSITest4* test = new TSITest4;
- a = test->VTest1(4, 2);
- b = test->VTest2(4, 2);
- c = test->VTest3(4, 2);
- d = test->VTest4(4, 2);
- e = test->NVTest1(4, 2);
- f = test->NVTest2(4, 2);
- delete test;
- }
- {
- TSITest5* test = new TSITest5;
- a = test->VTest1(4, 2);
- b = test->VTest2(4, 2);
- c = test->VTest3(4, 2);
- d = test->VTest4(4, 2);
- e = test->NVTest1(4, 2);
- f = test->NVTest2(4, 2);
- delete test;
- }
- {
- TSITest5 test;
- a = test.VTest1(4, 2);
- b = test.VTest2(4, 2);
- c = test.VTest3(4, 2);
- d = test.VTest4(4, 2);
- e = test.NVTest1(4, 2);
- f = test.NVTest2(4, 2);
- }
- CATCH_ALL
- fprintf(stderr, "TestLibrary is not installed!\n");
- ENDTRY
- CleanupLibraryManager();
- return 0;
- }
-