00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #pragma once
00011
00012
00013
00014
00015
00016
00017 #include <string>
00018
00019 #pragma warning( push )
00020 #pragma warning( disable : 4996 ) // vsprintf declared deprecated
00021
00022 namespace TestToolBox
00023 {
00024
00025 class CheckerForMultipleSequences;
00026 class TestEvents;
00027
00028
00029
00030 class CheckerForMultipleSequences
00031 {
00032 public:
00033
00034 CheckerForMultipleSequences(TestEvents & in_rTestEvents);
00035
00036
00037
00038 void DefineSequence (std::string const & in_nameSequence);
00039
00040
00041 void StoreExpectedEventWithinSelectedSequence(
00042 std::string const & in_expectedEvent,
00043 const char* in_fileName,
00044 const long in_lineNum);
00045
00046
00047
00048
00049 void CheckDefinedSequences (
00050 const char* in_fileName = 0,
00051 const long in_lineNum = 0);
00052
00053
00054 void ResetAll();
00055
00056
00057 void SetDetailedLog (bool in_detailedLog)
00058 {m_detailedLog = in_detailedLog;}
00059
00060 private:
00061 struct SequenceEntry;
00062 struct EventEntry
00063 {
00064 EventEntry(
00065 std::string const & in_eventTxt,
00066 int in_idxSequence,
00067 int in_idxEvent,
00068 const char* in_fileName,
00069 const long in_lineNum)
00070 : m_eventTxt (in_eventTxt)
00071 , m_eventPosition (-1)
00072 , m_idxSequence (in_idxSequence)
00073 , m_idxEvent (in_idxEvent)
00074 , m_fileName (const_cast<char*>(in_fileName))
00075 , m_lineNum (in_lineNum)
00076 {}
00077
00078
00079 std::string m_eventTxt;
00080
00081
00082
00083 int m_eventPosition;
00084
00085
00086 int m_idxSequence;
00087
00088
00089 int m_idxEvent;
00090
00091
00092 char* m_fileName;
00093 long m_lineNum;
00094 };
00095 typedef std::vector<EventEntry> EventEntries;
00096
00097 struct SequenceEntry
00098 {
00099 SequenceEntry (std::string const & in_nameSequence)
00100 : m_name (in_nameSequence)
00101 {}
00102 ~SequenceEntry()
00103 {
00104 }
00105
00106
00107 std::string m_name;
00108
00109
00110 EventEntries m_events;
00111 };
00112
00113 typedef std::vector<SequenceEntry> SequenceEntries;
00114
00115 struct SearchInfo
00116 {
00117 SearchInfo()
00118 : idxSequence (0)
00119 , idxEvent (0)
00120 , eventPos (0)
00121 , searchSucceeded (false)
00122 , searchFailed (false)
00123 , undoLastMatch (false)
00124 {}
00125
00126
00127 int idxSequence;
00128
00129
00130 int idxEvent;
00131
00132
00133 int eventPos;
00134
00135
00136 bool searchSucceeded;
00137
00138
00139 bool searchFailed;
00140
00141
00142
00143 bool undoLastMatch;
00144 };
00145
00146
00147 TestEvents& m_rTestEvents;
00148
00149
00150
00151 SequenceEntries m_sequences;
00152
00153
00154
00155
00156
00157 std::set<int> m_attachedIndices;
00158
00159
00160 std::vector<EventEntry*> m_recEv2SeqEv;
00161
00162
00163
00164 SequenceEntries m_sequencesBestMatch;
00165 std::vector<EventEntry*> m_recEv2SeqEvBestMatch;
00166 int m_numBestMatches;
00167
00168
00169 bool m_detailedLog;
00170
00171 private:
00172
00173 void CheckNextMatch (SearchInfo & io_searchInfo);
00174 void UndoLastMatch (SearchInfo & io_searchInfo);
00175 void MarkRecordedEventsAsChecked (void);
00176 int FindNextUncheckedPos (int in_startPos);
00177 bool FindFirstUnmatchedEvent(
00178 std::string & out_eventText,
00179 std::string & out_fileName,
00180 long & out_lineNum);
00181 void LogCheckResult(std::string const & in_headLine);
00182
00183 };
00184
00185 };
00186
00187
00188 #pragma warning( pop )
00189
00190