Chapter 1. Developer's Guide

Table of Contents

1.1. Introduction
1.2. Basic Expectations
1.2.1. Expectation Value
1.2.2. Expectation List
1.2.3. Constraint List
1.2.4. Expectation Set
1.2.5. Expectation Map
1.2.6. Expectation Boundary
1.2.7. ExpectationCounter
1.2.8. TrackingCounter
1.2.9. ExpectationSegment
1.2.10. Return Object List
1.3. Advanced Expectations
1.3.1. Introduction to Advanced Mock Objects
1.3.2. Visitable Mock Objects
1.3.3. Chainable Mock Objects
1.3.4. Poor Man's Mock Objects
1.4. Helpers
1.4.1. Asserter
1.4.2. Formatter
1.4.3. Throwables
1.5. Choosing a Unit Test Framework
1.5.1. CppUnit
1.5.2. CxxTest
1.5.3. Boost.Test
1.5.4. Selecting a Framework at Compile Time
1.6. Working With Embedded Systems
1.6.1. The Problem
1.6.2. The Solution
1.7. Support for Production Code
1.7.1. Reproducible Time Values
1.7.2. Accessing protected elements

1.1. Introduction

The following developer's guide is to get you started and to give you a quick overview over the features of mockpp. For a complete list of all functions please refer to the api documentation.

There are a few things that are not obvious but might become important to get started:

  • mockpp uses a data type String which is no data type of it's own but is a typedef to std::string or std::wstring depending on your choice. It also provides a minimum functionality for unicode if you compile for a unicode environment. See Section 1.2, “Compilation and Installation” how to do that.

    Since mockpp provides both environments with the same sources it uses some macros to convert string literals to the intended environment. You can check for the actual setting by adding a conditional #ifdef MOCKPP_UNICODE in your sources.

    • MOCKPP_PCHAR transforms a literal string either to a char* or to a wchar_t * by prepending an L for unicode.
    • In the same manner MOCKPP_STRING yields either a std::string or a std::wstring.
  • mockpp has no testing framework of it's own. But it includes a slightly modified version of CxxTest. It is also possible to use CppUnit or Boost.Test or others for that purpose. See the test and example files how to do it.

See Section 1.2.4, “Installing on other systems” for more options how to adjust this library.