Skip to content
Snippets Groups Projects
Commit a55f57a0 authored by janwych's avatar janwych
Browse files

SettableSpectrum to D_SettableSpectrum

git-svn-id: https://svnsrv.desy.de/desy/mtca4u_applications/DOOCS_Adapter/trunk@63 688d77b5-b833-4f6b-b27f-eb88d88625d6
parent 2e0256f0
No related branches found
No related tags found
No related merge requests found
#ifndef __SettableSpectrum__
#define __SettableSpectrum__
#ifndef __D_SettableSpectrum__
#define __D_SettableSpectrum__
#include "d_fct.h"
class SettableSpectrum : public D_spectrum //
{ //
public: //
//
SettableSpectrum (const char *pn, u_int maxl, EqFct *ef) : D_spectrum (pn, maxl, ef) {} //
//
//
std::vector<float> & get_spectrum (std::vector<float> & data) //
{ //
assert ( data.size() == static_cast<size_t>(max_length_) ); //
float * buffer = spectrum()->d_spect_array.d_spect_array_val; //
std::copy ( buffer, buffer+max_length_, data.begin() ); //
return data; //
} //
void set_spectrum (const std::vector<float> & data) //
{ //
assert ( data.size() == static_cast<size_t>(max_length_) ); //
float * buffer = spectrum()->d_spect_array.d_spect_array_val; //
std::copy ( data.begin(), data.end(), buffer ); //
} //
void fill(float const & t) //
{ //
float * buffer = spectrum()->d_spect_array.d_spect_array_val; //
std::fill ( buffer, buffer+max_length_, t ); //
} //
}; //
class D_SettableSpectrum : public D_spectrum //
{ //
public: //
//
D_SettableSpectrum (const char *pn, u_int maxl, EqFct *ef) : D_spectrum (pn, maxl, ef) {} //
//
//
std::vector<float> & get_spectrum (std::vector<float> & data) //
{ //
assert ( data.size() == static_cast<size_t>(max_length_) ); //
float * buffer = spectrum()->d_spect_array.d_spect_array_val; //
std::copy ( buffer, buffer+max_length_, data.begin() ); //
return data; //
} //
void set_spectrum (const std::vector<float> & data) //
{ //
assert ( data.size() == static_cast<size_t>(max_length_) ); //
float * buffer = spectrum()->d_spect_array.d_spect_array_val; //
std::copy ( data.begin(), data.end(), buffer ); //
} //
void fill(float const & t) //
{ //
float * buffer = spectrum()->d_spect_array.d_spect_array_val; //
std::fill ( buffer, buffer+max_length_, t ); //
} //
}; //
#endif /* __SettableSpectrum__ */
#endif /* __D_SettableSpectrum__ */
#define BOOST_TEST_MODULE test_settablespectrum
#define BOOST_TEST_MODULE test_dsettablespectrum
#include <boost/test/included/unit_test.hpp>
#include <boost/test/test_tools.hpp>
using namespace boost::unit_test;
#include "SettableSpectrum.hpp"
#include "D_SettableSpectrum.hpp"
#include <vector>
......@@ -16,11 +16,11 @@ using namespace boost::unit_test;
// ============================================================================
struct SettableSpectrumTestFixture {
struct D_SettableSpectrumTestFixture {
SettableSpectrum sspec;
D_SettableSpectrum sspec;
SettableSpectrumTestFixture() : sspec(NULL, 4, NULL) {}
D_SettableSpectrumTestFixture() : sspec(NULL, 4, NULL) {}
};
......@@ -28,7 +28,7 @@ struct SettableSpectrumTestFixture {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BOOST_FIXTURE_TEST_CASE( get, SettableSpectrumTestFixture )
BOOST_FIXTURE_TEST_CASE( get, D_SettableSpectrumTestFixture )
{
std::vector<float> expected;
expected.push_back(1);
......@@ -48,7 +48,7 @@ BOOST_FIXTURE_TEST_CASE( get, SettableSpectrumTestFixture )
BOOST_CHECK_EQUAL_COLLECTIONS(expected.begin(), expected.end(), actual.begin(), actual.end());
}
BOOST_FIXTURE_TEST_CASE( set, SettableSpectrumTestFixture )
BOOST_FIXTURE_TEST_CASE( set, D_SettableSpectrumTestFixture )
{
std::vector<float> expected;
expected.push_back(1);
......@@ -68,7 +68,7 @@ BOOST_FIXTURE_TEST_CASE( set, SettableSpectrumTestFixture )
BOOST_CHECK_EQUAL_COLLECTIONS(expected.begin(), expected.end(), actual.begin(), actual.end());
}
BOOST_FIXTURE_TEST_CASE( fill, SettableSpectrumTestFixture )
BOOST_FIXTURE_TEST_CASE( fill, D_SettableSpectrumTestFixture )
{
std::vector<float> expected;
expected.push_back(1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment