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 #ifndef TEST_RESULT_H_ 00026 #define TEST_RESULT_H_ 00027 00028 #include <LampUnit/SynchronizedObject.h> 00029 #include <Core/Container/ArrayList.h> 00030 00031 namespace LampUnit{ 00032 00033 class Test; 00034 class TestListener; 00035 class TestFailure; 00036 00037 //------------------------------------------------------------------------------ 00038 /** 00039 * テスト結果 00040 */ 00041 class TestResult : protected SynchronizedObject{ 00042 public: 00043 /** 00044 * コンストラクタ 00045 * @param synchronizationObject シンクロナイゼーションオブジェクト 00046 */ 00047 TestResult(SynchronizationObject* synchronizationObject = 0); 00048 00049 /// デストラクタ 00050 virtual ~TestResult(){} 00051 00052 /** 00053 * テストの開始 00054 * @param test 開始するテスト 00055 */ 00056 virtual void startTest(Test *test); 00057 00058 /** 00059 * テストの終了 00060 * @param test 終了するテスト 00061 */ 00062 virtual void endTest(Test *test); 00063 00064 /** 00065 * 失敗の追加 00066 * @param failure 追加する失敗 00067 */ 00068 virtual void addFailure(const TestFailure& failure); 00069 00070 /** 00071 * テストリスナの追加 00072 * @param testListener 追加するテストリスナ 00073 */ 00074 virtual void addListener(TestListener* testListener); 00075 00076 /** 00077 * テストの停止 00078 */ 00079 virtual void stop(); 00080 00081 /** 00082 * テストを停止するべきか 00083 * @retval true テストを停止する 00084 * @retval false テストを停止しない 00085 */ 00086 virtual bool shouldStop() const; 00087 00088 /** 00089 * 実行カウントの取得 00090 * @return 実行カウント 00091 */ 00092 virtual int getRunCount() const; 00093 00094 /** 00095 * 失敗カウントの取得 00096 * @return 失敗カウント 00097 */ 00098 virtual int getFailureCount() const; 00099 00100 /** 00101 * 成功したかどうか 00102 * @return 成功していればtrueを返す。 00103 */ 00104 virtual bool wasSuccessful() const; 00105 00106 protected: 00107 /// テストリスナ配列型 00108 typedef Lamp::ArrayList<TestListener*> TestListeners; 00109 /// テストリスナ配列 00110 TestListeners testListeners_; 00111 /// 停止フラグ 00112 bool shouldStop_; 00113 /// 実行数 00114 int executeCount_; 00115 /// 失敗数 00116 int failedCount_; 00117 00118 private: 00119 // コピーコンストラクタの隠蔽 00120 TestResult(const TestResult& copy); 00121 00122 // 代入コピーの隠蔽 00123 void operator =(const TestResult& copy); 00124 00125 }; 00126 00127 //------------------------------------------------------------------------------ 00128 } // End of namespace LampUnit 00129 #endif // End of TEST_RESULT_H_ 00130 //------------------------------------------------------------------------------