Patrick Venture | 21be45a | 2018-11-06 12:08:52 -0800 | [diff] [blame] | 1 | #include "firmware_handler.hpp" |
Patrick Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame^] | 2 | #include "image_mock.hpp" |
Patrick Venture | 21be45a | 2018-11-06 12:08:52 -0800 | [diff] [blame] | 3 | |
Patrick Venture | 5285462 | 2018-11-06 12:30:00 -0800 | [diff] [blame] | 4 | #include <algorithm> |
Patrick Venture | 21be45a | 2018-11-06 12:08:52 -0800 | [diff] [blame] | 5 | #include <memory> |
Patrick Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame^] | 6 | #include <vector> |
Patrick Venture | 21be45a | 2018-11-06 12:08:52 -0800 | [diff] [blame] | 7 | |
| 8 | #include <gtest/gtest.h> |
| 9 | |
| 10 | namespace blobs |
| 11 | { |
Patrick Venture | 5285462 | 2018-11-06 12:30:00 -0800 | [diff] [blame] | 12 | |
| 13 | TEST(FirmwareHandlerTest, CreateEmptyListVerifyFails) |
Patrick Venture | 21be45a | 2018-11-06 12:08:52 -0800 | [diff] [blame] | 14 | { |
| 15 | auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler({}, 0); |
Patrick Venture | 5285462 | 2018-11-06 12:30:00 -0800 | [diff] [blame] | 16 | EXPECT_EQ(handler, nullptr); |
| 17 | } |
| 18 | TEST(FirmwareHandlerTest, CreateEmptyListVerifyHasHash) |
| 19 | { |
Patrick Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame^] | 20 | ImageHandlerMock imageMock; |
| 21 | |
| 22 | std::vector<HandlerPack> blobs = { |
| 23 | {"asdf", &imageMock}, |
| 24 | }; |
| 25 | |
| 26 | auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(blobs, 0); |
Patrick Venture | 21be45a | 2018-11-06 12:08:52 -0800 | [diff] [blame] | 27 | auto result = handler->getBlobIds(); |
Patrick Venture | 5285462 | 2018-11-06 12:30:00 -0800 | [diff] [blame] | 28 | EXPECT_EQ(2, result.size()); |
| 29 | EXPECT_EQ(2, std::count(result.begin(), result.end(), "asdf") + |
| 30 | std::count(result.begin(), result.end(), |
| 31 | FirmwareBlobHandler::hashBlobID)); |
Patrick Venture | 21be45a | 2018-11-06 12:08:52 -0800 | [diff] [blame] | 32 | } |
| 33 | } // namespace blobs |