Skip to content

Commit

Permalink
Add FakeDisplay class for tests purpose.
Browse files Browse the repository at this point in the history
  • Loading branch information
przemek83 committed Sep 14, 2024
1 parent 258a98d commit 69fcea6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/Display.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include "ResourceType.h"

class Display
{
public:
Expand All @@ -15,6 +17,9 @@ class Display
int getHeight() const;
void setHeight(int height);

virtual int getResourceWidth(ResourceType resourceType) const = 0;
virtual int getResourceHeight(ResourceType resourceType) const = 0;

private:
int width_;
int height_;
Expand Down
4 changes: 2 additions & 2 deletions src/Screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ class Screen : public Display

static void clearScreenWithBlack();

int getResourceWidth(ResourceType resourceType) const;
int getResourceWidth(ResourceType resourceType) const override;

int getResourceHeight(ResourceType resourceType) const;
int getResourceHeight(ResourceType resourceType) const override;

static void refresh();

Expand Down
4 changes: 2 additions & 2 deletions test/DisplayTest.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include <catch2/catch_test_macros.hpp>

#include <src/Display.h>
#include "FakeDisplay.h"

TEST_CASE("Display initialization and properties", "[Display]")
{
Display display;
FakeDisplay display;

SECTION("Initialization")
{
Expand Down
18 changes: 18 additions & 0 deletions test/FakeDisplay.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once

#include <src/Display.h>

class FakeDisplay : public Display
{
public:
int getResourceWidth(
[[maybe_unused]] ResourceType resourceType) const override
{
return 0;
}
int getResourceHeight(
[[maybe_unused]] ResourceType resourceType) const override
{
return 0;
}
};

0 comments on commit 69fcea6

Please sign in to comment.