8 #include <gmock/gmock.h>
9 #include <gtest/gtest.h>
14 #include "../includes/pressure_utl.h"
16 #define KPA_MMH2O 101.97162129779
17 #define RATIO_VOLTAGE_DIVIDER 0.8192
22 static float filteredVout = 0;
23 double rawVout = sensorValue * 3.3 / 1024.0;
24 filteredVout = filteredVout + (rawVout - filteredVout) * 0.2;
30 double pressure = ((vOut /
V_SUPPLY) - 0.04) / 0.09;
32 if (pressure <= 0.0) {
49 std::vector<uint16_t>
input = {0, 100, 1000, 5000, 8000, 16000, 24000, 65535};
52 #define NEAR_EQUAL_DIFF 2
58 std::vector<uint16_t> outputTruth;
59 std::vector<uint16_t> output;
61 for (
size_t i = 0;
i < input.size();
i++) {
65 std::cout << outputTruth.back() <<
" " << output.back() << std::endl;
68 for (
int i = 0;
i < output.size();
i++) {
69 ASSERT_LE(std::abs(outputTruth[
i] - output[
i]), 2);
78 std::vector<uint16_t> outputTruth = {0, 0, 144, 984, 2182, 4545, 7839, 17762};
79 std::vector<uint16_t> output;
81 for (
size_t i = 0;
i < input.size();
i++) {
84 std::cout << output.back() << std::endl;
87 ASSERT_THAT(output, testing::ElementsAreArray(outputTruth));
Test Fixture to test the pression file.
std::vector< uint16_t > input
void resetFilteredRawPressure()
Reset the value of void filteredRawPressure to 0.
int16_t convertSensor2Pressure(uint32_t sensorValue)
Convert the analog value from sensor to a pressure value.
int16_t convertSensor2PressureFloat(uint16_t sensorValue)
Old converting function using floats.
TEST_F(PressionTest, testConvertSensor2PressureCompWithFloat)
Test convertSensor2Pressure with comparison with old floating point function.
#define RATIO_VOLTAGE_DIVIDER