1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
#ifndef TANGO_TESTS_CATCH2_UTILS_GENERATORS_H
#define TANGO_TESTS_CATCH2_UTILS_GENERATORS_H
#include "utils/options.h"
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include <catch2/generators/catch_generators_adapters.hpp>
#include <tango/tango.h>
namespace TangoTest
{
class IdlVersionGenerator : public Catch::Generators::IGenerator<int>
{
public:
IdlVersionGenerator(int min, int max) :
m_max{max},
m_curr{min}
{
if(g_options.only_idl_version)
{
int only = *g_options.only_idl_version;
if(only >= min && only <= max)
{
m_curr = only;
m_max = only;
}
else
{
SKIP("no idl version selected from range [" << min << "," << max << "] with idl-only=" << only);
}
}
}
int const &get() const override
{
return m_curr;
}
bool next() override
{
m_curr += 1;
return m_curr <= m_max;
}
private:
int m_max;
int m_curr;
};
inline Catch::Generators::GeneratorWrapper<int> idlversion(int min, int max = Tango::DevVersion)
{
return Catch::Generators::GeneratorWrapper<int>{new IdlVersionGenerator{min, max}};
}
} // namespace TangoTest
#endif
|