|
From: <mik...@us...> - 2003-12-24 10:49:52
|
Update of /cvsroot/sharedaemon/sharedaemon-ui-web/src/test
In directory sc8-pr-cvs1:/tmp/cvs-serv11724/src/test
Added Files:
TestException.cpp TestException.h TestHandler.cpp
TestHandler.h
Log Message:
24/12/2003 Barbeaux
* Implemented a basic Main program.
* Implemented generic Test handler.
* Implemented generic Exception handler.
* Started first revision of the project.
--- NEW FILE: TestException.cpp ---
/*
* This file is part of webInterface.
* Copyright (C) 2003 Mikael Barbeaux <mik...@us...>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "TestException.h"
#include "../exceptions/ThreadException.h"
#include <iostream>
using namespace std;
/**
* Creates a TestException object.
*/
TestException::TestException() : TestHandler() {
}
/**
* Runs the tester.
*/
void TestException::run() {
/** This test tries to launch an exception
* and to catch it. Then it displays the message
* sent by the exception before exiting. */
cout << "Start of TestException" <<endl;
try {
cout << " Create a ThreadException" << endl;
ThreadError error = MutexError;
ThreadException excp(error,"Mutex isn't initialized");
cout << " Throws exception" << endl;
throw excp;
cout << " Exception hasn't been thrown" << endl;
}
catch(Exception& e) {
cout << " Exception catched" << endl;
// displays the exception message
cout << " " << e.getMessage() << endl;
}
cout << "End of TestException" << endl;
}
--- NEW FILE: TestException.h ---
/*
* This file is part of webInterface.
* Copyright (C) 2003 Mikael Barbeaux <mik...@us...>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _TEST_EXCEPTION_H_
#define _TEST_EXCEPTION_H_
#include "../exceptions/Exception.h"
#include "TestHandler.h"
/**
* Defines a Test handler for testing exceptions objects.
* Implements the TestHandler object and tests exceptions.
*/
class TestException : public TestHandler {
public:
/**
* Creates an object for testing an exception handler.
*/
TestException();
/**
* Runs the tester.
*/
virtual void run();
};
#endif
--- NEW FILE: TestHandler.cpp ---
/*
* This file is part of webInterface.
* Copyright (C) 2003 Mikael Barbeaux <mik...@us...>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "TestHandler.h"
/**
* Creates a TestHandler object.
* Does nothing...
*/
TestHandler::TestHandler() {
}
/**
* TestHandler destructor
* Does nothing...
*/
TestHandler::~TestHandler() {
}
--- NEW FILE: TestHandler.h ---
/*
* This file is part of webInterface.
* Copyright (C) 2003 Mikael Barbeaux <mik...@us...>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _TEST_HANDLER_H_
#define _TEST_HANDLER_H_
/**
* Defines a generic object for making test units.
* If you want to create your own test class, you need to
* create a new subclass implementing the run()
* method.
*/
class TestHandler{
public:
/**
* Creates a TestHandler object.
*/
TestHandler();
/**
* Destructor for TestHandler
*/
virtual ~TestHandler();
/**
* Runs the test
* Needs to be implemented into subclasses.
*/
virtual void run() = 0;
};
#endif
|