\hypertarget{classTestMain}{
\section{TestMain Class Reference}
\label{classTestMain}\index{TestMain@{TestMain}}
}


A helper class for test programs.  




{\ttfamily \#include $<$test\_\-main.hh$>$}

\subsection*{Classes}
\begin{DoxyCompactItemize}
\item 
class \hyperlink{classTestMain_1_1Arg}{Arg}
\end{DoxyCompactItemize}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classTestMain_a146c56268634dc620a4f1b6128c0200d}{
\hyperlink{classTestMain_a146c56268634dc620a4f1b6128c0200d}{TestMain} (int argc, char $\ast$const argv\mbox{[}$\,$\mbox{]})}
\label{classTestMain_a146c56268634dc620a4f1b6128c0200d}

\begin{DoxyCompactList}\small\item\em Start \hyperlink{protocolthe-p}{the} parsing of command line arguments. \item\end{DoxyCompactList}\item 
string \hyperlink{classTestMain_a7e45341b08e90cc80f908e705f78351a}{get\_\-optional\_\-args} (const string \&short\_\-form, const string \&long\_\-form, const string \&description)
\begin{DoxyCompactList}\small\item\em Get an optional argument from \hyperlink{protocolthe-p}{the} command line. \item\end{DoxyCompactList}\item 
bool \hyperlink{classTestMain_a92148190e3b21bcd620572a0bea29f6c}{get\_\-optional\_\-flag} (const string \&short\_\-form, const string \&long\_\-form, const string \&description)
\begin{DoxyCompactList}\small\item\em Get an optional flag from \hyperlink{protocolthe-p}{the} command line. \item\end{DoxyCompactList}\item 
void \hyperlink{classTestMain_a88af46b7db52fbc0bbd112db675c1807}{complete\_\-args\_\-parsing} ()
\begin{DoxyCompactList}\small\item\em Complete parsing \hyperlink{protocolthe-p}{the} arguments. \item\end{DoxyCompactList}\item 
bool \hyperlink{classTestMain_a20b126cdbd490f4a296e48c813861d83}{get\_\-verbose} () const 
\begin{DoxyCompactList}\small\item\em Get \hyperlink{protocolthe-p}{the} state of \hyperlink{protocolthe-p}{the} verbose flag. \item\end{DoxyCompactList}\item 
int \hyperlink{classTestMain_a05874fbaefd20d1725203f936f2fbc4a}{get\_\-verbose\_\-level} () const 
\begin{DoxyCompactList}\small\item\em Get \hyperlink{protocolthe-p}{the} \hyperlink{protocolthe-p}{the} verbose level, should only be used if \hyperlink{classTestMain_a20b126cdbd490f4a296e48c813861d83}{get\_\-verbose()} is true. \item\end{DoxyCompactList}\item 
void \hyperlink{classTestMain_aaaa84b2f7263d4c69969c677522f6425}{run} (string test\_\-name, XorpCallback1$<$ bool, \hyperlink{classTestInfo}{TestInfo} \& $>$::RefPtr cb)
\begin{DoxyCompactList}\small\item\em Run a test function/method. \item\end{DoxyCompactList}\item 
const string \hyperlink{classTestMain_afd022c15b172dee7546084194e4d4db5}{usage} ()
\item 
void \hyperlink{classTestMain_aeb76f8154e803744cabb37ba5e855267}{failed} (string error)
\begin{DoxyCompactList}\small\item\em Mark \hyperlink{protocolthe-p}{the} tests as having failed. \item\end{DoxyCompactList}\item 
int \hyperlink{classTestMain_a31e35ae712a6c4f5d6ca5bcf37fffad2}{exit} ()
\begin{DoxyCompactList}\small\item\em Must be called at \hyperlink{protocolthe-p}{the} end of \hyperlink{protocolthe-p}{the} tests. \item\end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Private Attributes}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classTestMain_aa25622a06432b7aedf5946db9c91f4ac}{
string {\bfseries \_\-progname}}
\label{classTestMain_aa25622a06432b7aedf5946db9c91f4ac}

\item 
\hypertarget{classTestMain_a55bb2f30320ad44670b2a843a6426648}{
list$<$ \hyperlink{classTestMain_1_1Arg}{Arg} $>$ {\bfseries \_\-args}}
\label{classTestMain_a55bb2f30320ad44670b2a843a6426648}

\item 
\hypertarget{classTestMain_af2bd09e93e9b041b35281d90a0a630e8}{
bool {\bfseries \_\-verbose}}
\label{classTestMain_af2bd09e93e9b041b35281d90a0a630e8}

\item 
\hypertarget{classTestMain_add2080bd561763a8c6430df804408b6e}{
int {\bfseries \_\-verbose\_\-level}}
\label{classTestMain_add2080bd561763a8c6430df804408b6e}

\item 
\hypertarget{classTestMain_abab5d6dce2761fe568d618a3ec61cb3d}{
bool {\bfseries \_\-exit\_\-status}}
\label{classTestMain_abab5d6dce2761fe568d618a3ec61cb3d}

\item 
\hypertarget{classTestMain_a9a25ecc2aeb127a2d52c4ffe29880e85}{
string {\bfseries \_\-error\_\-string}}
\label{classTestMain_a9a25ecc2aeb127a2d52c4ffe29880e85}

\item 
\hypertarget{classTestMain_ae2497cfc1ff54160b7e6934442bce39d}{
string {\bfseries \_\-usage}}
\label{classTestMain_ae2497cfc1ff54160b7e6934442bce39d}

\end{DoxyCompactItemize}


\subsection{Detailed Description}
A helper class for test programs. This class is used to parse \hyperlink{protocolthe-p}{the} command line arguments and return \hyperlink{protocolthe-p}{the} exit status from \hyperlink{protocolthe-p}{the} test functions/methods. An example of how to use this class can be found in test\_\-test\_\-main.cc. 

\subsection{Member Function Documentation}
\hypertarget{classTestMain_a88af46b7db52fbc0bbd112db675c1807}{
\index{TestMain@{TestMain}!complete\_\-args\_\-parsing@{complete\_\-args\_\-parsing}}
\index{complete\_\-args\_\-parsing@{complete\_\-args\_\-parsing}!TestMain@{TestMain}}
\subsubsection[{complete\_\-args\_\-parsing}]{\setlength{\rightskip}{0pt plus 5cm}void TestMain::complete\_\-args\_\-parsing (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classTestMain_a88af46b7db52fbc0bbd112db675c1807}


Complete parsing \hyperlink{protocolthe-p}{the} arguments. 

Process generic arguments and verify that there are no arguments left unprocessed. \hypertarget{classTestMain_a31e35ae712a6c4f5d6ca5bcf37fffad2}{
\index{TestMain@{TestMain}!exit@{exit}}
\index{exit@{exit}!TestMain@{TestMain}}
\subsubsection[{exit}]{\setlength{\rightskip}{0pt plus 5cm}int TestMain::exit (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classTestMain_a31e35ae712a6c4f5d6ca5bcf37fffad2}


Must be called at \hyperlink{protocolthe-p}{the} end of \hyperlink{protocolthe-p}{the} tests. 

\begin{DoxyReturn}{Returns}
The status of \hyperlink{protocolthe-p}{the} tests. Should be passed to \hyperlink{classTestMain_a31e35ae712a6c4f5d6ca5bcf37fffad2}{exit()}. 
\end{DoxyReturn}
\hypertarget{classTestMain_aeb76f8154e803744cabb37ba5e855267}{
\index{TestMain@{TestMain}!failed@{failed}}
\index{failed@{failed}!TestMain@{TestMain}}
\subsubsection[{failed}]{\setlength{\rightskip}{0pt plus 5cm}void TestMain::failed (
\begin{DoxyParamCaption}
\item[{string}]{error}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classTestMain_aeb76f8154e803744cabb37ba5e855267}


Mark \hyperlink{protocolthe-p}{the} tests as having failed. 

Used for setting an error condition from outside a test.


\begin{DoxyParams}{Parameters}
{\em error} & Error string. \\
\hline
\end{DoxyParams}
\hypertarget{classTestMain_a7e45341b08e90cc80f908e705f78351a}{
\index{TestMain@{TestMain}!get\_\-optional\_\-args@{get\_\-optional\_\-args}}
\index{get\_\-optional\_\-args@{get\_\-optional\_\-args}!TestMain@{TestMain}}
\subsubsection[{get\_\-optional\_\-args}]{\setlength{\rightskip}{0pt plus 5cm}string TestMain::get\_\-optional\_\-args (
\begin{DoxyParamCaption}
\item[{const string \&}]{short\_\-form, }
\item[{const string \&}]{long\_\-form, }
\item[{const string \&}]{description}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classTestMain_a7e45341b08e90cc80f908e705f78351a}


Get an optional argument from \hyperlink{protocolthe-p}{the} command line. 


\begin{DoxyParams}{Parameters}
{\em short\_\-form} & The short form of \hyperlink{protocolthe-p}{the} argument e.g. \char`\"{}-\/t\char`\"{}. \\
\hline
{\em long\_\-form} & The long form of \hyperlink{protocolthe-p}{the} argument e.g. \char`\"{}-\/-\/testing\char`\"{}. \\
\hline
{\em description} & The description of this argument that will be used in \hyperlink{protocolthe-p}{the} usage message. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
\hyperlink{protocolthe-p}{the} argument or \char`\"{}\char`\"{} if not found or an error occured in previous parsing of \hyperlink{protocolthe-p}{the} arguments. 
\end{DoxyReturn}
\hypertarget{classTestMain_a92148190e3b21bcd620572a0bea29f6c}{
\index{TestMain@{TestMain}!get\_\-optional\_\-flag@{get\_\-optional\_\-flag}}
\index{get\_\-optional\_\-flag@{get\_\-optional\_\-flag}!TestMain@{TestMain}}
\subsubsection[{get\_\-optional\_\-flag}]{\setlength{\rightskip}{0pt plus 5cm}bool TestMain::get\_\-optional\_\-flag (
\begin{DoxyParamCaption}
\item[{const string \&}]{short\_\-form, }
\item[{const string \&}]{long\_\-form, }
\item[{const string \&}]{description}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classTestMain_a92148190e3b21bcd620572a0bea29f6c}


Get an optional flag from \hyperlink{protocolthe-p}{the} command line. 


\begin{DoxyParams}{Parameters}
{\em short\_\-form} & The short form of \hyperlink{protocolthe-p}{the} argument e.g. \char`\"{}-\/t\char`\"{}. \\
\hline
{\em long\_\-form} & The long form of \hyperlink{protocolthe-p}{the} argument e.g. \char`\"{}-\/-\/testing\char`\"{}. \\
\hline
{\em description} & The description of this argument that will be used in \hyperlink{protocolthe-p}{the} usage message. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
true if \hyperlink{protocolthe-p}{the} flag is present or false found or an error occured in previous parsing of \hyperlink{protocolthe-p}{the} arguments. 
\end{DoxyReturn}
\hypertarget{classTestMain_a20b126cdbd490f4a296e48c813861d83}{
\index{TestMain@{TestMain}!get\_\-verbose@{get\_\-verbose}}
\index{get\_\-verbose@{get\_\-verbose}!TestMain@{TestMain}}
\subsubsection[{get\_\-verbose}]{\setlength{\rightskip}{0pt plus 5cm}bool TestMain::get\_\-verbose (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classTestMain_a20b126cdbd490f4a296e48c813861d83}


Get \hyperlink{protocolthe-p}{the} state of \hyperlink{protocolthe-p}{the} verbose flag. 

Used by test programs that don't use \hyperlink{protocolthe-p}{the} run method to run tests. \hypertarget{classTestMain_a05874fbaefd20d1725203f936f2fbc4a}{
\index{TestMain@{TestMain}!get\_\-verbose\_\-level@{get\_\-verbose\_\-level}}
\index{get\_\-verbose\_\-level@{get\_\-verbose\_\-level}!TestMain@{TestMain}}
\subsubsection[{get\_\-verbose\_\-level}]{\setlength{\rightskip}{0pt plus 5cm}int TestMain::get\_\-verbose\_\-level (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classTestMain_a05874fbaefd20d1725203f936f2fbc4a}


Get \hyperlink{protocolthe-p}{the} \hyperlink{protocolthe-p}{the} verbose level, should only be used if \hyperlink{classTestMain_a20b126cdbd490f4a296e48c813861d83}{get\_\-verbose()} is true. 

Used by test programs that don't use \hyperlink{protocolthe-p}{the} run method to run \hyperlink{protocolthe-p}{the} tests. \hypertarget{classTestMain_aaaa84b2f7263d4c69969c677522f6425}{
\index{TestMain@{TestMain}!run@{run}}
\index{run@{run}!TestMain@{TestMain}}
\subsubsection[{run}]{\setlength{\rightskip}{0pt plus 5cm}void TestMain::run (
\begin{DoxyParamCaption}
\item[{string}]{test\_\-name, }
\item[{XorpCallback1$<$ bool, {\bf TestInfo} \& $>$::RefPtr}]{cb}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classTestMain_aaaa84b2f7263d4c69969c677522f6425}


Run a test function/method. 

The test function/method is passed a \hyperlink{classTestInfo}{TestInfo}. The test function/method should return true for success and "false for failure.

To run a function call \char`\"{}test\char`\"{}: run(\char`\"{}test\char`\"{}, callback(test));


\begin{DoxyParams}{Parameters}
{\em test\_\-name} & The name of \hyperlink{protocolthe-p}{the} test. \\
\hline
{\em cb} & Callback object. \\
\hline
\end{DoxyParams}
\hypertarget{classTestMain_afd022c15b172dee7546084194e4d4db5}{
\index{TestMain@{TestMain}!usage@{usage}}
\index{usage@{usage}!TestMain@{TestMain}}
\subsubsection[{usage}]{\setlength{\rightskip}{0pt plus 5cm}const string TestMain::usage (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classTestMain_afd022c15b172dee7546084194e4d4db5}
\begin{DoxyReturn}{Returns}
The usage string. 
\end{DoxyReturn}


The documentation for this class was generated from the following file:\begin{DoxyCompactItemize}
\item 
/home/greearb/git/xorp.ct.github/xorp/libxorp/test\_\-main.hh\end{DoxyCompactItemize}
