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_STRING_LISTENER_H_ 00026 #define TEST_STRING_LISTENER_H_ 00027 00028 #include <LampUnit/TestListener.h> 00029 00030 namespace Lamp{ 00031 class Logger; 00032 } 00033 00034 namespace LampUnit{ 00035 00036 //------------------------------------------------------------------------------ 00037 /** 00038 * 文字列リスナ 00039 */ 00040 class TestStringListener : public TestListener{ 00041 public: 00042 /** 00043 * コンストラクタ 00044 * @param fileName ログファイル名。NULLだとログを残しません。 00045 */ 00046 TestStringListener(const char* fileName = "UnitTestLog.txt"); 00047 00048 /** 00049 * デストラクタ 00050 */ 00051 virtual ~TestStringListener(); 00052 00053 /** 00054 * テスト開始 00055 * @param test 開始するテスト 00056 */ 00057 virtual void startTest(Test* test); 00058 00059 /** 00060 * 失敗の追加 00061 * 00062 * メソッド終了後でもfailureの情報が必要な場合はfailureをコピーする。 00063 * @param failure 失敗したテストの情報 00064 */ 00065 virtual void addFailure(const TestFailure& failure); 00066 00067 /** 00068 * テスト終了 00069 * @param test 終了するテスト 00070 */ 00071 virtual void endTest(Test* test); 00072 00073 /** 00074 * 出力 00075 * @param string 出力文字列 00076 */ 00077 virtual void print(const char* string); 00078 00079 /** 00080 * フォーマット出力 00081 * 00082 * 可変長引数に対応したデバッグ出力メソッド。 00083 * @param format フォーマット 00084 * @param ... 可変長引数 00085 * @return 出力文字数 00086 */ 00087 virtual void printFormat(const char* format, ...); 00088 00089 private: 00090 // テストカウント 00091 int testCount_; 00092 // ロガー 00093 Lamp::Logger* logger_; 00094 00095 // 最大文字列長 00096 static const int maxStringLength_ = 1024; 00097 00098 }; 00099 00100 //------------------------------------------------------------------------------ 00101 } // End of namespace LampUnit 00102 #endif // End of TEST_STRING_LISTENER_H_ 00103 //------------------------------------------------------------------------------