diff options
author | Deepak Kodihalli <dkodihal@in.ibm.com> | 2016-11-30 05:19:45 -0600 |
---|---|---|
committer | Deepak Kodihalli <dkodihal@in.ibm.com> | 2016-12-08 12:40:08 -0600 |
commit | 901c5d92d10cc23c52d9ff306b3ecea276ce67a4 (patch) | |
tree | ad55f9fd3a8428444e31e8e13d58259545a34d2c | |
parent | 2bba75d47657e35f9031e5bade0949a03399ce3f (diff) | |
download | openpower-vpd-parser-901c5d92d10cc23c52d9ff306b3ecea276ce67a4.tar.gz openpower-vpd-parser-901c5d92d10cc23c52d9ff306b3ecea276ce67a4.zip |
tests: unit-test for Store::get API
Change-Id: Ie67427f9496bb8f9712ef80e987c39903a66cd17
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | test/Makefile.am | 8 | ||||
-rw-r--r-- | test/store/store.cpp | 36 |
4 files changed, 47 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am index 35e22cc..14cdc1e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,3 +28,5 @@ openpower_read_vpd_SOURCES = \ 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 @@ AS_IF([test "x$enable_oe_sdk" == "xyes"], ) 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; +} |