diff options
| author | Deepak Kodihalli <dkodihal@in.ibm.com> | 2016-12-02 07:10:14 -0600 |
|---|---|---|
| committer | Deepak Kodihalli <dkodihal@in.ibm.com> | 2016-12-08 12:40:08 -0600 |
| commit | 79f9eee0da046577955a68d647b011c1850bec9b (patch) | |
| tree | d76f3b9bf63936049fba9c443b985562042ed00c /test | |
| parent | 901c5d92d10cc23c52d9ff306b3ecea276ce67a4 (diff) | |
| download | openpower-vpd-parser-79f9eee0da046577955a68d647b011c1850bec9b.tar.gz openpower-vpd-parser-79f9eee0da046577955a68d647b011c1850bec9b.zip | |
tests: unit-test for parse() API
Change-Id: I9912102d442f2c00ce70514a4a65f25e1552fc19
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
Diffstat (limited to 'test')
| -rw-r--r-- | test/Makefile.am | 7 | ||||
| -rw-r--r-- | test/parser/parser.cpp | 30 | ||||
| -rw-r--r-- | test/test.vpd | bin | 0 -> 165 bytes |
3 files changed, 37 insertions, 0 deletions
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 @@ TESTS = $(check_PROGRAMS) 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 Binary files differnew file mode 100644 index 0000000..bc4fc0e --- /dev/null +++ b/test/test.vpd |

