JayBeams  0.1
Another project to have fun coding.
ut_create_triangle_timeseries.cpp
Go to the documentation of this file.
3 
4 #include <boost/test/unit_test.hpp>
5 #include <complex>
6 
7 namespace {
8 
9 template <typename value_type>
10 void check_create_triangle() {
11  std::vector<value_type> ts;
13  value_type sum = 0;
14  for (auto const& i : ts) {
15  sum += i;
16  }
17  jb::testing::check_small(sum, 1.0 / ts.size());
18 }
19 
20 } // anonymous namespace
21 
22 /**
23  * @test Test jb::testing::create_triangle_timeseries with float
24  *
25  * Usually I do not spend time testing helper functions for tests, but
26  * in this case the helper has a lot of template code and we want to
27  * validate this before too long.
28  */
29 BOOST_AUTO_TEST_CASE(create_triangle_timeseries_float) {
30  check_create_triangle<float>();
31 }
32 
33 /**
34  * @test Test jb::testing::create_triangle_timeseries with double
35  */
36 BOOST_AUTO_TEST_CASE(create_triangle_timeseries_double) {
37  check_create_triangle<double>();
38 }
39 
40 /**
41  * @test Test jb::testing::create_triangle_timeseries with std::complex<float>
42  */
43 BOOST_AUTO_TEST_CASE(create_triangle_timeseries_cfloat) {
44  check_create_triangle<std::complex<float>>();
45 }
46 
47 /**
48  * @test Test jb::testing::create_triangle_timeseries with std::complex<double>
49  */
50 BOOST_AUTO_TEST_CASE(create_triangle_timeseries_cdouble) {
51  check_create_triangle<std::complex<double>>();
52 }
void check_small(floating t, double small)
Verify that a floating point value is "close enough" to a small number.
void create_triangle_timeseries(int nsamples, timeseries &ts)
Create a simple timeseries where the values look like a triangle.
BOOST_AUTO_TEST_CASE(create_triangle_timeseries_float)