gem5  v20.1.0.0
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

◆ checkVal()

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 49 of file unittest.cc.

References cprintf().

◆ failures()

unsigned UnitTest::failures ( )

Function that returns the current number of failed checks.

Returns
Number of checks that have failed so far.

Definition at line 68 of file unittest.cc.

◆ passes()

unsigned UnitTest::passes ( )

Function that returns the current number of passed checks.

Returns
Number of checks that have passed so far.

Definition at line 67 of file unittest.cc.

◆ printOnPass() [1/2]

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 64 of file unittest.cc.

◆ printOnPass() [2/2]

void UnitTest::printOnPass ( bool  newVal)

Function for setting print on pass.

Parameters
newValThe new setting.

Definition at line 65 of file unittest.cc.

◆ printResults()

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 71 of file unittest.cc.

References cprintf().

◆ reset()

void UnitTest::reset ( )

Zero the number of passes and failures so far.

Definition at line 79 of file unittest.cc.

◆ setCase()

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 86 of file unittest.cc.


Generated on Wed Sep 30 2020 14:03:14 for gem5 by doxygen 1.8.17