Next: , Up: C++ API Reference   [Contents][Index]


5.1 C++ Suite Reference

C++ Type: suite

Main driver of the execution, C++ representation of the C type micro_benchmark_suite (see Suite Reference.)


C++ Constructor: suite::suite (char const* name)
C++ Constructor: suite::suite (SL const& name)

Preconditions:

  1. name points to a valid C string.

Effects:

  1. Creation of a new suite.

Postconditions:

  1. The created suite can be used.
  2. The name of the created suite is equivalent to name.


C++ Method: char const* suite::name () const

Preconditions:

  1. *this is a valid object.

Effects:

  1. None.

Postconditions:

  1. The created suite can be used.
  2. The name of the created suite is equivalent to name.


C++ Type: <with-constraints>

Internal type for the registration of a constraint function together with the test. The provided value micro_benchmark::with_constraints has this type.


Note: The following interface is going to change, to allow member function pointers and current register_class functionality.

C++ Method Template: test_case suite::register_test (char const* name, T&& test, SU&& set_up = <default_set_up>, TD&& tear_down = <default_tear_down>)
C++ Method Template: test_case suite::register_test (SL const& name, T&& test, SU&& set_up = <default_set_up>, TD&& tear_down = <default_tear_down>)

Preconditions:

  1. *this is a valid object.
  2. T is a valid test type.
  3. SU is a valid set up type.
  4. TD is a valid tear down type.
  5. name points to a C string.
  6. test is a valid object or a pointer to a valid function.
  7. set_up is a valid object or a pointer to a valid function.
  8. tear_down is a valid object or a pointer to a valid function.

Effects:

  1. Register with name the test defined by test.
  2. Register set_up as its set up function if it is provided. Otherwise use the default provided by the library is used.
  3. Register tear_down as its tear down function if it is provided. Otherwise use the default provided by the library is used.

Postconditions:

  1. The returned value is a handle to the created test case.
  2. The returned value test_case::name is equivalent to name.
  3. The registered test will be executed by suite::run unless its execution is disabled.


C++ Method Template: test_case suite::register_test (<with-constraints>, C&& constraints, char const* name, T&& test, SU&& set_up = <default_set_up>, TD&& tear_down = <default_tear_down>)
C++ Method Template: test_case suite::register_test (<with-constraints>, C&& constraints, SL const& name, T&& test, SU&& set_up = <default_set_up>, TD&& tear_down = <default_tear_down>)

Preconditions:

  1. *this is a valid object.
  2. C is a valid constraint type.
  3. T is a valid test type.
  4. SU is a valid set up type.
  5. TD is a valid tear down type.
  6. name points to a valid C string.
  7. constraints is a valid object.
  8. test is a valid object or a pointer to a valid function.
  9. set_up is a valid object or a pointer to a valid function.
  10. tear_down is a valid object or a pointer to a valid function.

Effects:

  1. Register with name the test defined by test.
  2. Register set_up as its set up function if it is provided. Otherwise use the default provided by the library is used.
  3. Register tear_down as its tear down function if it is provided. Otherwise use the default provided by the library is used.
  4. constraints is called with the defined test as its parameter.

Postconditions:

  1. The returned value is a handle to the created test case.
  2. The returned value test_case::name is equivalent to name.
  3. The registered test will be executed by suite::run unless its execution is disabled by the constraints function or later modifications of the test_case handle.


C++ Method Template: test_case suite::register_class (char const* name, T&& test)
C++ Method Template: test_case suite::register_class (Sl const& name, T&& test)

Preconditions:

  1. *this is a valid object.
  2. T defines an instance method operator() or operator() const with the right signature.
  3. name points to a valid C string.

Effects:

  1. The test defined by test in the suite with name.
  2. If T has a valid static member constraints, it is called with the defined test as its parameter.

Postconditions:

  1. The returned value is a handle to the created test case.
  2. The returned value test_case::name is equivalent to name.
  3. The registered test will be executed by suite::run unless its execution is disabled by the constraints function or later modifications of the test_case handle.
  4. If T has a valid instance member set_up, it is called before the test execution.
  5. If T has a valid instance member tear_down, it is called after the test execution.


C++ Method: std::vector<test_case> suite::tests () const

Preconditions:

  1. *this is a valid object.

Effects:

  1. None.

Postconditions:

  1. The returned value contains a handles of the registered tests up to this.


C++ Method: void suite::run ()

Preconditions:

  1. *this is a valid object.
  2. this->run has not been called.

Effects:

  1. Run the registered and enabled tests.

Postconditions:

  1. The suite contains a report of the executions.


C++ Method: report suite::stored_report () const

Preconditions:

  1. *this is a valid object.
  2. this->run has been called.

Effects:

  1. None.

Postconditions:

  1. The returned value contains a handles of the registered tests up to this.



Next: C++ Test Reference, Up: C++ API Reference   [Contents][Index]