Elements  6.2
A C++ base framework for the Euclid Software.
Public Member Functions | List of all members
Elements::Examples::UnitTestExample Class Reference

This class has been created to demonstrate unit testing. More...

#include <UnitTestExample.h>

Public Member Functions

double average (const std::vector< int > &v)
 Returns a particular version of the "average" of the vector values. More...
 

Detailed Description

This class has been created to demonstrate unit testing.

Definition at line 40 of file UnitTestExample.h.

Member Function Documentation

◆ average()

double Elements::Examples::UnitTestExample::average ( const std::vector< int > &  v)

Returns a particular version of the "average" of the vector values.

This method computes the "average" as the median of the given values if there are more than 5 values. Otherwise, it returns the mean value instead of the median.

If an even number of numbers is given, the returned value is the mean of the two middle values.

Parameters
vThe values to compute the "average" for
Returns
The "average" of the given values
Exceptions
Elements::ExceptionIf the given vector is empty

Definition at line 35 of file UnitTestExample.cpp.

References std::accumulate(), std::vector< T >::begin(), std::vector< T >::end(), std::vector< T >::size(), and std::sort().

Here is the call graph for this function:

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