Add IpmbSensor unit tests
Because everything was packed into IpmbSensor.cpp, which also included
main(), this commit breaks it up into the patterns we have in other
sensors, with <X>main.cpp containing the things for main.
While this doesn't clean up everything, it at least makes
processResponse unit testable, and adds one minor test for it.
Change-Id: I1eabf650ff635211e5b9a94816c2ffce250ed252
Signed-off-by: Ed Tanous <ed@tanous.net>
diff --git a/tests/test_IpmbSensor.cpp b/tests/test_IpmbSensor.cpp
new file mode 100644
index 0000000..3168993
--- /dev/null
+++ b/tests/test_IpmbSensor.cpp
@@ -0,0 +1,23 @@
+#include "IpmbSensor.hpp"
+
+#include <cstddef>
+#include <cstdint>
+#include <vector>
+
+#include <gtest/gtest.h>
+
+namespace
+{
+
+TEST(IPMBSensor, Byte0)
+{
+ std::vector<uint8_t> data;
+ data.push_back(42);
+
+ double responseValue = 0.0;
+ size_t errCount = 0;
+ EXPECT_TRUE(IpmbSensor::processReading(ReadingFormat::byte0, 0, data,
+ responseValue, errCount));
+ EXPECT_EQ(responseValue, 42.0);
+}
+} // namespace