tests: unit-test for Store::get API
Change-Id: Ie67427f9496bb8f9712ef80e987c39903a66cd17
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
diff --git a/Makefile.am b/Makefile.am
index 35e22cc..14cdc1e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -28,3 +28,5 @@
impl.cpp \
parser.cpp \
write.cpp
+
+SUBDIRS = test
diff --git a/configure.ac b/configure.ac
index 0cb15a4..33b9ae7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -40,5 +40,5 @@
)
AC_CONFIG_HEADERS([config.h])
-AC_CONFIG_FILES([Makefile])
+AC_CONFIG_FILES([Makefile test/Makefile])
AC_OUTPUT
diff --git a/test/Makefile.am b/test/Makefile.am
new file mode 100644
index 0000000..71591f0
--- /dev/null
+++ b/test/Makefile.am
@@ -0,0 +1,8 @@
+AM_CPPFLAGS = -I$(top_srcdir)
+
+check_PROGRAMS =
+
+TESTS = $(check_PROGRAMS)
+
+check_PROGRAMS += store_test
+store_test_SOURCES = store/store.cpp
diff --git a/test/store/store.cpp b/test/store/store.cpp
new file mode 100644
index 0000000..32b403c
--- /dev/null
+++ b/test/store/store.cpp
@@ -0,0 +1,36 @@
+#include <cassert>
+#include <string>
+#include <unordered_map>
+#include <utility>
+#include "defines.hpp"
+#include "store.hpp"
+
+void runTests()
+{
+ using namespace openpower::vpd;
+
+ // Test Store::get API
+ {
+ Parsed vpd;
+ using inner = Parsed::mapped_type;
+ inner i;
+
+ i.emplace("SN", "1001");
+ i.emplace("PN", "F001");
+ i.emplace("DR", "Fake FRU");
+ vpd.emplace("VINI", i);
+
+ Store s(std::move(vpd));
+
+ assert(("1001" == s.get<Record::VINI, record::Keyword::SN>()));
+ assert(("F001" == s.get<Record::VINI, record::Keyword::PN>()));
+ assert(("Fake FRU" == s.get<Record::VINI, record::Keyword::DR>()));
+ }
+}
+
+int main()
+{
+ runTests();
+
+ return 0;
+}