45 lines
976 B
C++
45 lines
976 B
C++
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
|
|
#include <doctest/doctest.h>
|
|
#include <iostream>
|
|
|
|
|
|
#include "../device/adc_device_attribute.h"
|
|
|
|
using namespace adc;
|
|
|
|
template <typename T>
|
|
struct V {
|
|
static T getter() { return _v; }
|
|
static void setter(const T& v) { _v = v; }
|
|
|
|
static bool validator(const T& v)
|
|
{
|
|
if (v < 1)
|
|
return false;
|
|
else
|
|
return true;
|
|
}
|
|
|
|
private:
|
|
inline static T _v = 1;
|
|
};
|
|
|
|
|
|
TEST_CASE("[ADC DEVICE ATTRIBUTE]")
|
|
{
|
|
double av = -10;
|
|
using vv = V<unsigned>;
|
|
|
|
using attr_t = AdcDeviceAttribute<std::string_view>;
|
|
|
|
// attr_t attr(AdcValueHolder::_defaultTrivialConvTypes, "ATTR_A", attr_t::ReadWrite, vv::getter, vv::setter,
|
|
// vv::validator);
|
|
attr_t attr("ATTR_A", attr_t::ReadWrite, vv::getter, vv::setter, vv::validator);
|
|
|
|
// attr = 10.7;
|
|
// av = attr;
|
|
|
|
// std::cout << "ATTR = " << av << "\n";
|
|
std::cout << "ATTR = " << (unsigned)attr << "\n";
|
|
}
|