gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
UnitTest Namespace Reference

Functions

void checkVal (const char *file, const unsigned line, const char *test, const bool result)
 Function that actually handles checking whether an EXPECT_* passed. More...
 
bool printOnPass ()
 Print on pass is a switch that specifies whether to print a message even when a check passes. More...
 
void printOnPass (bool newVal)
 Function for setting print on pass. More...
 
unsigned passes ()
 Function that returns the current number of passed checks. More...
 
unsigned failures ()
 Function that returns the current number of failed checks. More...
 
unsigned printResults ()
 Function to call at the end of a test that prints an overall result and a summary of how many checks passed and failed. More...
 
void reset ()
 Zero the number of passes and failures so far. More...
 
void setCase (const char *newCase)
 Sets the current test case. More...
 

Function Documentation

void UnitTest::checkVal ( const char *  file,
const unsigned  line,
const char *  test,
const bool  result 
)

Function that actually handles checking whether an EXPECT_* passed.

This should be used through the EXPECT macros below and not called directly.

Parameters
fileThe name of the file this check is in.
lineThe line number this check is on.
testText specifying what check is being performed.
resultWhether the check passed.

Definition at line 51 of file unittest.cc.

References cprintf().

unsigned UnitTest::failures ( )

Function that returns the current number of failed checks.

Returns
Number of checks that have failed so far.

Definition at line 70 of file unittest.cc.

unsigned UnitTest::passes ( )

Function that returns the current number of passed checks.

Returns
Number of checks that have passed so far.

Definition at line 69 of file unittest.cc.

bool UnitTest::printOnPass ( )

Print on pass is a switch that specifies whether to print a message even when a check passes.

It's default value is whether or not "PRINT_ON_PASS" is set in the calling environment. What it's actually set to is ignored. Function for retrieving the current setting for print on pass.

Returns
The current setting.

Definition at line 66 of file unittest.cc.

void UnitTest::printOnPass ( bool  newVal)

Function for setting print on pass.

Parameters
newValThe new setting.

Definition at line 67 of file unittest.cc.

unsigned UnitTest::printResults ( )

Function to call at the end of a test that prints an overall result and a summary of how many checks passed and failed.

main() should return the return value of this function which is the number of failed checks.

Returns
Number of failed checks.

Definition at line 73 of file unittest.cc.

References cprintf().

Referenced by main().

void UnitTest::reset ( )

Zero the number of passes and failures so far.

Definition at line 81 of file unittest.cc.

void UnitTest::setCase ( const char *  newCase)

Sets the current test case.

Test cases are used to group checks together and describe what that group is doing. Setting a new case defines the start of a new group and the end of the previous one. The case string is used in place and not copied, so don't modify or invalidate it until a new case label is installed.

Parameters
newCaseThe name of the new test case.

Definition at line 88 of file unittest.cc.

Referenced by main().


Generated on Fri Jun 9 2017 13:04:41 for gem5 by doxygen 1.8.6