PX4 Firmware
PX4 Autopilot Software http://px4.io
UnitTest Class Referenceabstract

Base class to be used for unit tests. More...

#include <unit_test.h>

Inheritance diagram for UnitTest:
Collaboration diagram for UnitTest:

Public Member Functions

 UnitTest ()=default
 
virtual ~UnitTest ()=default
 
virtual bool run_tests (void)=0
 Override to run your unit tests. More...
 
void print_results ()
 Prints results from running of unit tests. More...
 

Protected Member Functions

virtual void _init (void)
 Run before each unit test. Override to provide custom behavior. More...
 
virtual void _cleanup (void)
 Run after each unit test. Override to provide custom behavior. More...
 
void _print_assert (const char *msg, const char *test, const char *file, int line)
 
void _print_compare (const char *msg, const char *v1_text, int v1, const char *v2_text, int v2, const char *file, int line)
 

Protected Attributes

int _tests_run {0}
 The number of individual unit tests run. More...
 
int _tests_failed {0}
 The number of unit tests which failed. More...
 
int _tests_passed {0}
 The number of unit tests which passed. More...
 
int _assertions {0}
 Total number of assertions tested by all unit tests. More...
 

Detailed Description

Base class to be used for unit tests.

Definition at line 54 of file unit_test.h.

Constructor & Destructor Documentation

◆ UnitTest()

UnitTest::UnitTest ( )
default

◆ ~UnitTest()

virtual UnitTest::~UnitTest ( )
virtualdefault

Member Function Documentation

◆ _cleanup()

virtual void UnitTest::_cleanup ( void  )
inlineprotectedvirtual

Run after each unit test. Override to provide custom behavior.

Reimplemented in MavlinkFtpTest.

Definition at line 192 of file unit_test.h.

◆ _init()

virtual void UnitTest::_init ( void  )
inlineprotectedvirtual

Run before each unit test. Override to provide custom behavior.

Reimplemented in MavlinkFtpTest.

Definition at line 191 of file unit_test.h.

◆ _print_assert()

void UnitTest::_print_assert ( const char *  msg,
const char *  test,
const char *  file,
int  line 
)
inlineprotected

Definition at line 194 of file unit_test.h.

◆ _print_compare()

void UnitTest::_print_compare ( const char *  msg,
const char *  v1_text,
int  v1,
const char *  v2_text,
int  v2,
const char *  file,
int  line 
)
inlineprotected

Definition at line 199 of file unit_test.h.

◆ print_results()

void UnitTest::print_results ( )
inline

Prints results from running of unit tests.

Definition at line 66 of file unit_test.h.

◆ run_tests()

virtual bool UnitTest::run_tests ( void  )
pure virtual

Override to run your unit tests.

Unit tests should be called using ut_run_test macro.

Returns
true: all unit tests succeeded, false: one or more unit tests failed

Implemented in MicroBenchORB::MicroBenchORB, MixerTest, MicroBenchMatrix::MicroBenchMatrix, MicroBenchMath::MicroBenchMath, MicroBenchHRT::MicroBenchHRT, MathlibTest, SearchMinTest, IntTest, FloatTest, AutoDeclinationTest, StateMachineHelperTest, ListTest, ParameterTest, MatrixTest, MavlinkFtpTest, BezierQuadTest, IntrusiveQueueTest, SmoothZTest, VersioningTest, RCTest, and SF0XTest.

Member Data Documentation

◆ _assertions

int UnitTest::_assertions {0}
protected

Total number of assertions tested by all unit tests.

Definition at line 208 of file unit_test.h.

◆ _tests_failed

◆ _tests_passed

int UnitTest::_tests_passed {0}
protected

The number of unit tests which passed.

Definition at line 207 of file unit_test.h.

◆ _tests_run

int UnitTest::_tests_run {0}
protected

The number of individual unit tests run.

Definition at line 205 of file unit_test.h.


The documentation for this class was generated from the following file: