Name

Orthodox

Description

The template Orthodox (see Figure C-9) is a subclass of TestCase. When specialized for a class, it tests the class for “orthodoxy,” represented by the following conditions:

  • The class has a default (no argument) constructor

  • The class has equality (==) and inequality (!=) operators

  • The class has an assignment (=) operator

  • The class has a negation (!) operator

  • The class has a copy constructor

The test verifies not only that ClassUnderTest has these operations, but also that the operations’ semantics are correct. For example, double negation should result in equality.

The main purpose of Orthodox is to serve as a working example of a templated test case.

Orthodox belongs to the namespace CppUnit. It is declared and implemented in extensions/Orthodox.h.

The templated test class Orthodoxy
Figure C-9. The templated test class Orthodoxy

Declaration

template<typename ClassUnderTest>
   class Orthodox : public TestCase

Constructors/Destructors

Orthodox( )

A constructor.

Public Methods

ClassUnderTest call(ClassUnderTest object)

Returns object.

void runTest( )

Runs the orthodoxy tests.

Protected/Private Methods

None.

Attributes

None.

Get Unit Test Frameworks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.