Willy Tu | 067ece1 | 2022-06-16 02:07:06 -0700 | [diff] [blame] | 1 | #include "helper.hpp" |
| 2 | |
Willy Tu | 067ece1 | 2022-06-16 02:07:06 -0700 | [diff] [blame] | 3 | #include <ipmid/api-types.hpp> |
Patrick Williams | 5250957 | 2023-05-10 07:51:18 -0500 | [diff] [blame] | 4 | |
Willy Tu | 067ece1 | 2022-06-16 02:07:06 -0700 | [diff] [blame] | 5 | #include <optional> |
| 6 | #include <span> |
| 7 | #include <tuple> |
| 8 | #include <utility> |
| 9 | #include <vector> |
| 10 | |
| 11 | #include <gtest/gtest.h> |
| 12 | |
| 13 | namespace blobs |
| 14 | { |
| 15 | std::vector<std::uint8_t> |
| 16 | validateReply(ipmi::RspType<std::vector<uint8_t>> reply, bool hasData) |
| 17 | { |
| 18 | // Reply is in the form of |
| 19 | // std::tuple<ipmi::Cc, std::optional<std::tuple<RetTypes...>>> |
| 20 | EXPECT_EQ(::ipmi::ccSuccess, std::get<0>(reply)); |
| 21 | |
| 22 | auto actualReply = std::get<1>(reply); |
| 23 | EXPECT_TRUE(actualReply.has_value()); |
Willy Tu | 7509f4e | 2023-08-22 22:32:04 -0700 | [diff] [blame] | 24 | if (!actualReply.has_value()) |
| 25 | return std::vector<uint8_t>{}; |
Willy Tu | 067ece1 | 2022-06-16 02:07:06 -0700 | [diff] [blame] | 26 | |
| 27 | auto data = std::get<0>(*actualReply); |
| 28 | EXPECT_EQ(hasData, !data.empty()); |
| 29 | |
| 30 | return hasData ? data : std::vector<uint8_t>{}; |
| 31 | } |
| 32 | |
| 33 | } // namespace blobs |