home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-11-19 | 3.1 KB | 154 lines | [TEXT/MPS ] |
- /*
- File: TestLibrary.cp
-
- Contains: Files for the test library
-
- Copyright: © 1991-1994 by Apple Computer, Inc., all rights reserved.
-
- */
-
-
- #ifndef __TESTCLASS__
- #include "TestClass.h"
- #endif
- #ifndef __OSUTILS__
- #include <OSUtils.h>
- #endif
- #ifndef __STDARG__
- #include <stdarg.h>
- #endif
-
- /**********************************************************************
- ** TTestTool methods
- ***********************************************************************/
-
- TTestTool::TTestTool()
- {
- #ifndef USEMPW
- fPrint = NULL;
- fPrintWorld = NULL;
- #endif
- fPool = NULL;
- }
-
- TTestTool::TTestTool(TStandardPool* thePool)
- {
- #ifndef USEMPW
- fPrint = NULL;
- fPrintWorld = NULL;
- #endif
- SetPool(thePool);
- }
-
- TTestTool::~TTestTool()
- {}
-
- #ifndef USEMPW
- void TTestTool::SetPrintf(PrintfFunc func)
- {
- fPrintWorld = (Ptr) SetCurrentA5();
- fPrint = func;
- }
- #endif
-
- void TTestTool::Printf(const char* str, ...) const
- {
- va_list args;
-
- #ifdef USEMPW
- va_start(args, str);
- vprintf(str, args);
- fflush(stdout);
- #else
- if (fPrint)
- {
- Ptr oldWorld = (Ptr) SetA5((long)fPrintWorld); // Set up the fPrint's world
- va_start(args, str);
- (*fPrint)(str, args);
- SetA5((long)oldWorld); // restore the world
- }
- #endif
- }
-
- /**********************************************************************
- ** TNumber methods
- ***********************************************************************/
-
- TNumber::TNumber(short num)
- {
- fNumber = num;
- }
-
- TNumber::~TNumber()
- {}
-
- Boolean TNumber::IsEqual(const void* obj) const
- {
- return (fNumber == ((const TNumber*)obj)->fNumber) ? true : false;
- }
-
- unsigned long TNumber::Hash() const
- {
- return fNumber;
- }
-
- /**********************************************************************
- ** TNumberHasher methods
- ***********************************************************************/
-
- TNumberHasher::TNumberHasher()
- {}
-
- TNumberHasher::~TNumberHasher()
- {}
-
- unsigned long TNumberHasher::Hash(const void* obj) const
- {
- return ((const TNumber*)obj)->Hash();
- }
-
- /*******************************************************************************
- ** Some Constants
- ********************************************************************************/
-
- const size_t kFastIMValue = 1771875;
- const size_t kFastIAValue = 2416;
- const size_t kFastICValue = 374441;
-
- size_t gSeed = 0;
-
- size_t RandomNumber(size_t lo, size_t hi)
- {
- gSeed = (gSeed*kFastIAValue + kFastICValue) % kFastIMValue;
- return lo + ((hi - lo + 1)*gSeed)/kFastIMValue;
- }
-
- size_t StringToNum(char* str)
- {
- size_t num = 0;
- while (*str >= '0' && *str <= '9')
- num = num*10 + (*str++) - '0';
- return num;
- }
-
- /**********************************************************************
- ** Load other test tools
- ***********************************************************************/
-
- #include "TestLinkedList.cp"
- #include "TestAllocLinkedList.cp"
- #include "TestPriorityList.cp"
- #include "TestTimeScheduler.cp"
- #include "TestTaskScheduler.cp"
- #include "TestArbitrator.cp"
- #include "TestTimeStamp.cp"
- #include "TestRandom.cp"
- #include "TestHashList.cp"
- #include "TestStandardPool.cp"
- #include "TestFSet.cp"
- #include "TestNoVTable.cp"
- #include "TestTimings.cp"
- #include "TestExceptions.cp"
- #include "TestMisc.cp"
-
-