blob: 858754933e502f165786e9ce96e281b5faac5481 [file] [log] [blame]
Willy Tu067ece12022-06-16 02:07:06 -07001#include "helper.hpp"
2
Willy Tu067ece12022-06-16 02:07:06 -07003#include <ipmid/api-types.hpp>
Patrick Williams52509572023-05-10 07:51:18 -05004
Willy Tu067ece12022-06-16 02:07:06 -07005#include <optional>
6#include <span>
7#include <tuple>
8#include <utility>
9#include <vector>
10
11#include <gtest/gtest.h>
12
13namespace blobs
14{
15std::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 Tu7509f4e2023-08-22 22:32:04 -070024 if (!actualReply.has_value())
25 return std::vector<uint8_t>{};
Willy Tu067ece12022-06-16 02:07:06 -070026
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