Sources/MemoryClassTest.cp

/*
    File:       MemoryClassTest.cp
 
    Contains:   TMemory is a simple object checks heap and stack values, as well as changes them.
                TMemoryClassTest.cp contains the TMemory class test functions.
 
    Written by: Kent Sandvik    
 
    Copyright:  Copyright © 1993-1999 by Apple Computer, Inc., All Rights Reserved.
 
                You may incorporate this Apple sample source code into your program(s) without
                restriction. This Apple sample source code has been provided "AS IS" and the
                responsibility for its operation is yours. You are not permitted to redistribute
                this Apple sample source code as "Apple sample source code" after having made
                changes. If you're going to re-distribute the source, we require that you make
                it clear in the source that the code was descended from Apple sample source
                code, but that you've made changes.
 
    Change History (most recent first):
                8/18/1999   Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
                
 
*/
 
#ifndef _MEMORYCLASS_
#include "MemoryClass.h"
#endif
 
// CONSTANTS
const long kMyMinHeap = 200 * 1024;
const long kMyMinStack = 60 * 1024;
 
// We will test out various stack and heap sizes. It is recommended to make a separate
// application (SIOW or something similar) for testing this out. Don't forget to add the
// special kStackResource -- the test program needs this one.
 
void main(void)
{
    cout << "Start of the TMemory object testÉ\n";
 
    // Create a TMemory object. 
    TMemory myMemory(kMyMinHeap, kMyMinStack);
 
    // Check out current sizes.
    cout << "Current Stack size is = " << myMemory.GetStackSize() << '\n';
    cout << "Current Heap size is = " << myMemory.GetHeapSize() << '\n';
 
    // Change stack size.
    cout << "I'm changing the stack size to 60k \n";
    myMemory.SetStackSize(60 * 1024);
    cout << "New Stack size is = " << myMemory.GetStackSize() << '\n';
    cout << "I'm increasing the stack size by 10k \n";
    myMemory.IncreaseStackSize(10 * 1024);
    cout << "New Stack size is = " << myMemory.GetStackSize() << '\n';
    cout << "Current Heap size is = " << myMemory.GetHeapSize() << '\n';
 
    // Check heap size values, valid?
    if (myMemory.CheckHeapSize())
        cout << "OK with the heap size, > 200k\n";
    else
        cout << "Problems with the heap size, < 200k\n";
 
    // Check stack size values, valid?
    if (myMemory.CheckStackSize())
        cout << "OK with the stack size, > 60k\n";
    else
        cout << "Problems with the stack size, < 60k\n";
 
    // Test of resource handling
    if (myMemory.SetStackSizeFromResources())
        cout << "OK with setting the stack size from resources, stack size = " << myMemory.GetStackSize() << '\n';
    else
        cout << "No resources, couldn't set stack size from a resource value\n";
 
    cout << "End of the TMemory object test!\n";
}
 
// _________________________________________________________________________________________________________ //
 
/*  Change History (most recent last):
  No        Init.   Date        Comment
  1         khs     1/2/93      New file
  2         khs     1/3/93      Cleanup
*/