Willy Tu | ff3cd8e | 2021-09-14 22:49:55 -0700 | [diff] [blame] | 1 | #include "helper.hpp" |
| 2 | |
| 3 | #include <ipmid/api-types.hpp> |
| 4 | #include <optional> |
| 5 | #include <span> |
| 6 | #include <utility> |
| 7 | |
| 8 | namespace google |
| 9 | { |
| 10 | namespace ipmi |
| 11 | { |
| 12 | |
| 13 | std::pair<std::uint8_t, std::vector<std::uint8_t>> |
| 14 | ValidateReply(::ipmi::RspType<std::uint8_t, std::vector<uint8_t>> reply, |
| 15 | bool hasData) |
| 16 | { |
| 17 | // Reply is in the form of |
| 18 | // std::tuple<ipmi::Cc, std::optional<std::tuple<RetTypes...>>> |
| 19 | EXPECT_EQ(::ipmi::ccSuccess, std::get<0>(reply)); |
| 20 | |
| 21 | auto actualReply = std::get<1>(reply); |
| 22 | EXPECT_TRUE(actualReply.has_value()); |
| 23 | |
| 24 | auto subcommand = std::get<0>(*actualReply); |
| 25 | auto data = std::get<1>(*actualReply); |
| 26 | EXPECT_EQ(hasData, !data.empty()); |
| 27 | |
| 28 | return std::make_pair(subcommand, hasData ? data : std::vector<uint8_t>{}); |
| 29 | } |
| 30 | |
| 31 | } // namespace ipmi |
| 32 | } // namespace google |