tests: unit-test for parse() API
Change-Id: I9912102d442f2c00ce70514a4a65f25e1552fc19
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
diff --git a/.gitignore b/.gitignore
index 5422c9f..71665e0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,3 +19,8 @@
*.lo
*.la
test-driver
+*.dirstamp
+parser_test
+store_test
+*.log
+*.trs
diff --git a/test/Makefile.am b/test/Makefile.am
index 71591f0..428cd0b 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -6,3 +6,10 @@
check_PROGRAMS += store_test
store_test_SOURCES = store/store.cpp
+
+check_PROGRAMS += parser_test
+parser_test_SOURCES = \
+ parser/parser.cpp \
+ ../impl.cpp \
+ ../parser.cpp \
+ ../write.cpp
diff --git a/test/parser/parser.cpp b/test/parser/parser.cpp
new file mode 100644
index 0000000..eda30af
--- /dev/null
+++ b/test/parser/parser.cpp
@@ -0,0 +1,30 @@
+#include <defines.hpp>
+#include <store.hpp>
+#include <parser.hpp>
+#include <cassert>
+#include <fstream>
+#include <iterator>
+
+void runTests()
+{
+ using namespace openpower::vpd;
+
+ // Test parse() API
+ {
+ std::ifstream vpdFile("test.vpd", std::ios::binary);
+ Binary vpd((std::istreambuf_iterator<char>(vpdFile)),
+ std::istreambuf_iterator<char>());
+
+ auto vpdStore = parse(std::move(vpd));
+
+ assert(("P012" ==
+ vpdStore.get<Record::VINI, record::Keyword::CC>()));
+ }
+}
+
+int main()
+{
+ runTests();
+
+ return 0;
+}
diff --git a/test/test.vpd b/test/test.vpd
new file mode 100644
index 0000000..bc4fc0e
--- /dev/null
+++ b/test/test.vpd
Binary files differ