Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

TestResult.cpp

Go to the documentation of this file.
00001 //------------------------------------------------------------------------------
00002 // Lamp : Open source game middleware
00003 // Copyright (C) 2004  Junpei Ohtani ( Email : junpee@users.sourceforge.jp )
00004 //
00005 // This library is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 //
00010 // This library is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with this library; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 //------------------------------------------------------------------------------
00019 
00020 /** @file
00021  * テスト結果実装
00022  * @author Junpee
00023  */
00024 
00025 #include <LampBasic.h>
00026 #include "LampUnit/TestResult.h"
00027 #include "LampUnit/TestListener.h"
00028 
00029 namespace LampUnit{
00030 
00031 //------------------------------------------------------------------------------
00032 // コンストラクタ
00033 TestResult::TestResult(SynchronizationObject* synchronizationObject) :
00034     SynchronizedObject(synchronizationObject), shouldStop_(false),
00035     executeCount_(0), failedCount_(0){
00036 }
00037 //------------------------------------------------------------------------------
00038 // テストの停止
00039 void TestResult::stop(){
00040     SynchronizedBlock synchronizedBlock(synchronizationObject_);
00041     shouldStop_ = true;
00042 }
00043 //------------------------------------------------------------------------------
00044 // テストを停止するべきか
00045 bool TestResult::shouldStop() const{
00046     SynchronizedBlock synchronizedBlock(synchronizationObject_);
00047     return shouldStop_;
00048 }
00049 //------------------------------------------------------------------------------
00050 // テストリスナの追加
00051 void TestResult::addListener(TestListener* testListener){
00052     SynchronizedBlock synchronizedBlock(synchronizationObject_);
00053     testListeners_.add(testListener);
00054 }
00055 //------------------------------------------------------------------------------
00056 // テストの開始
00057 void TestResult::startTest(Test *test){
00058     SynchronizedBlock synchronizedBlock(synchronizationObject_);
00059     executeCount_++;
00060     int count = testListeners_.getCount();
00061     for(int i = 0; i < count; i++){
00062         testListeners_[i]->startTest(test);
00063     }
00064 }
00065 //------------------------------------------------------------------------------
00066 // テストの終了
00067 void TestResult::endTest(Test *test){
00068     SynchronizedBlock synchronizedBlock(synchronizationObject_);
00069     int count = testListeners_.getCount();
00070     for(int i = 0; i < count; i++){
00071         testListeners_[i]->endTest(test);
00072     }
00073 }
00074 //------------------------------------------------------------------------------
00075 // 失敗の追加
00076 void TestResult::addFailure(const TestFailure& failure){
00077     SynchronizedBlock synchronizedBlock(synchronizationObject_);
00078     failedCount_++;
00079     int count = testListeners_.getCount();
00080     for(int i = 0; i < count; i++){
00081         testListeners_[i]->addFailure(failure);
00082     }
00083 }
00084 //------------------------------------------------------------------------------
00085 // 実行カウントの取得
00086 int TestResult::getRunCount() const{
00087     SynchronizedBlock synchronizedBlock(synchronizationObject_);
00088     return executeCount_;
00089 }
00090 //------------------------------------------------------------------------------
00091 // 失敗カウントの取得
00092 int TestResult::getFailureCount() const{
00093     SynchronizedBlock synchronizedBlock(synchronizationObject_);
00094     return failedCount_;
00095 }
00096 //------------------------------------------------------------------------------
00097 /**
00098  * 成功したかどうか
00099  * @return 成功していればtrueを返す。
00100  */
00101 bool TestResult::wasSuccessful() const{
00102     SynchronizedBlock synchronizedBlock(synchronizationObject_);
00103     return (failedCount_ == 0);
00104 }
00105 //------------------------------------------------------------------------------
00106 } // End of namespace LampUnit
00107 //------------------------------------------------------------------------------

Generated on Wed Mar 16 10:29:54 2005 for LampUnit by doxygen 1.3.2