Found a matcher for the tests
This commit is contained in:
@@ -1,7 +1,10 @@
|
|||||||
#include "app/rom.h"
|
#include "app/rom.h"
|
||||||
|
|
||||||
|
#include <gmock/gmock.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include "absl/status/statusor.h"
|
#include "absl/status/statusor.h"
|
||||||
|
|
||||||
#define BUILD_HEADER(command, length) (command << 5) + (length - 1)
|
#define BUILD_HEADER(command, length) (command << 5) + (length - 1)
|
||||||
@@ -12,6 +15,9 @@ namespace rom_test {
|
|||||||
using yaze::app::CompressionPiece;
|
using yaze::app::CompressionPiece;
|
||||||
using yaze::app::ROM;
|
using yaze::app::ROM;
|
||||||
|
|
||||||
|
using ::testing::ElementsAreArray;
|
||||||
|
using ::testing::TypedEq;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
Bytes ExpectCompressDataLoadedOk(ROM& rom, uchar* in, int in_size) {
|
Bytes ExpectCompressDataLoadedOk(ROM& rom, uchar* in, int in_size) {
|
||||||
@@ -66,10 +72,12 @@ TEST(ROMTest, NewDecompressionPieceOk) {
|
|||||||
|
|
||||||
TEST(ROMTest, DecompressionValidCommand) {
|
TEST(ROMTest, DecompressionValidCommand) {
|
||||||
ROM rom;
|
ROM rom;
|
||||||
uchar simple_copy_input[4] = {BUILD_HEADER(0, 2), 42, 69, 0xFF};
|
std::array<uchar, 4> simple_copy_input = {BUILD_HEADER(0, 2), 42, 69, 0xFF};
|
||||||
uchar simple_copy_output[2] = {42, 69};
|
uchar simple_copy_output[2] = {42, 69};
|
||||||
auto data = ExpectDecompressDataLoadedOk(rom, simple_copy_input, 4);
|
auto decompressed_result =
|
||||||
for (int i = 0; i < 2; i++) ASSERT_EQ(simple_copy_output[i], data[i]);
|
ExpectDecompressDataLoadedOk(rom, simple_copy_input.data(), 4);
|
||||||
|
ASSERT_THAT(simple_copy_output,
|
||||||
|
ElementsAreArray(decompressed_result.data(), 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(ROMTest, DecompressionMixingCommand) {
|
TEST(ROMTest, DecompressionMixingCommand) {
|
||||||
|
|||||||
Reference in New Issue
Block a user