blob: 6f16b5531abc15fc0f94fbb7114e84d5ec2eca4c [file] [log] [blame]
Willy Tuff3cd8e2021-09-14 22:49:55 -07001#include "helper.hpp"
2
3#include <ipmid/api-types.hpp>
4#include <optional>
5#include <span>
6#include <utility>
7
8namespace google
9{
10namespace ipmi
11{
12
13std::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