remove functionpointer sensor (#442)

* remove functionpointer sensor

* remove function_pointer_sensor.cpp from tests.mk
This commit is contained in:
Nathan Schulte 2024-06-14 14:17:09 -05:00 committed by GitHub
parent 8336187eeb
commit cd38fa1f61
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 0 additions and 68 deletions

View File

@ -1,40 +0,0 @@
/**
* @file function_pointer_sensor.h
* @brief A sensor to provide a bridge from old getX()-style functions to the new sensor registry.
*
* @date September 12, 2019
* @author Matthew Kennedy, (c) 2019
*/
#pragma once
#include "sensor.h"
/* This class is intended as a bridge to bridge from old getMySensor() functions
* to the new system. This way, producers and consumers can be independently
* updated to the new system, with sensors being usable either way for some time.
*/
class FunctionPointerSensor final : public Sensor {
public:
FunctionPointerSensor(SensorType type, float (*func)())
: Sensor(type)
, m_func(func) {}
SensorResult get() const final {
float result = m_func();
// check for NaN
bool valid = !(result != result);
if (!valid) {
return unexpected;
}
return result;
}
void showInfo(const char* /*sensorName*/) const override {}
private:
float (*m_func)();
};

View File

@ -1,27 +0,0 @@
#include "pch.h"
#include "function_pointer_sensor.h"
class SensorFunctionPointer : public ::testing::Test {
protected:
void SetUp() override {
Sensor::resetRegistry();
}
void TearDown() override {
Sensor::resetRegistry();
}
};
float testFunc() {
return 23;
}
TEST_F(SensorFunctionPointer, TestValue) {
FunctionPointerSensor dut(SensorType::Clt, testFunc);
ASSERT_TRUE(dut.Register());
auto result = Sensor::get(SensorType::Clt);
EXPECT_TRUE(result.Valid);
EXPECT_FLOAT_EQ(result.Value, 23);
}

View File

@ -79,7 +79,6 @@ TESTS_SRC_CPP = \
tests/test_lambda_monitor.cpp \
tests/sensor/basic_sensor.cpp \
tests/sensor/func_sensor.cpp \
tests/sensor/function_pointer_sensor.cpp \
tests/sensor/mock_sensor.cpp \
tests/sensor/sensor_reader.cpp \
tests/sensor/lin_func.cpp \