/////////////////////////////////////////////////////////////// // assert.cpp -- support for design by contract // // ver 1.0 // // Language: Visual C++, ver 6.0 // // Platform: Micron Dual Pentium Pro 200, Win NT 4.0 // // Application: CSE784, Pr2, Fall 1998 // // Author: Jim Fawcett, CST 2-187, Syracuse Univ. // // (315) 443-3948, fawcett@ECS.syr.edu // /////////////////////////////////////////////////////////////// // Based on "Exception-Based Assertion Mechanism for C++ // // David Welch and Scott Strong // // Journal of Object Oriented Programming, July/August 1998 // /////////////////////////////////////////////////////////////// #include "assert.h" //----< constructor >------------------------------------------ Assertion::Assertion ( Assertion::Type assertionType, const char *reason, const char *file, int inputLine ) : theType(assertionType), theReason((char*)reason), theFile((char*)file), theLine(inputLine) { } //----< copy constructor >------------------------------------- Assertion::Assertion(const Assertion &other) : theType(other.getType()), theReason((char*)other.getReason()), theFile((char*)other.getFile()), theLine(other.getLine()) { } //----< destructor >------------------------------------------- Assertion::~Assertion() { } //----< assignment >------------------------------------------- Assertion& Assertion::operator=(const Assertion &other) { if(this!=&other) { theType = other.getType(); theReason = (char*)other.getReason(); theFile = (char*)other.getFile(); theLine = other.getLine(); } return *this; } // //----< getReason >-------------------------------------------- const char* Assertion::getReason() const { return theReason; } //----< getFile >---------------------------------------------- const char* Assertion::getFile() const { return theFile; } //----< getLine >---------------------------------------------- int Assertion::getLine() const { return theLine; } //----< getType >---------------------------------------------- Assertion::Type Assertion::getType() const { return theType; }