3#include "gtest/gtest.h"
6using ::testing::EmptyTestEventListener;
7using ::testing::InitGoogleTest;
9using ::testing::TestEventListeners;
10using ::testing::TestInfo;
11using ::testing::TestPartResult;
12using ::testing::TestSuite;
13using ::testing::UnitTest;
17TEST(ImageDataTests, PixelAssignment)
19 Color pixel1(1,2,3, 50);
20 Color pixel2 = pixel1;
22 EXPECT_EQ(pixel1.
a, pixel2.
a);
23 EXPECT_EQ(pixel1.
r, pixel2.
r);
24 EXPECT_EQ(pixel1.
g, pixel2.
g);
25 EXPECT_EQ(pixel1.
b, pixel2.
b);
28TEST(ImageDataTests, ImageDataAssignment)
31 Color const testColor(115U, 100U, 10U, 150U);
32 image1.
Fill(testColor);
40 for(
unsigned int y = 0; y < image1.
GetHeight(); ++y )
42 for(
unsigned int x = 0; x < image1.
GetWidth(); ++x )
49TEST(ImageDataTests, GetImageDataEmpty)
58TEST(ImageDataTests, InappropriateAccess)
63 EXPECT_THROW(image.
GetPixel(4, 4), std::runtime_error);
66TEST(ImageDataTest, SaveLoadTextureJpg)
68 std::string
const filepath{
"test_jpeg_texture_file.jpg"};
73 ImageData image2(
"test_jpeg_texture_file.jpg");
80TEST(ImageDataTest, SaveLoadTexturePng)
82 std::string
const filepath{
"test_png_texture_file.png" };
87 ImageData image2(
"test_png_texture_file.png");
94TEST(ImageDataTest, IncorrectTextureFilepath)
96 std::string
const filepath{
"missing_texture_file.png" };
98 EXPECT_THROW(
ImageData image(filepath), std::runtime_error);
Represents raw 2D image data stored in memory.
unsigned int GetWidth() const
Returns the image width.
void Fill(Color color)
Fills the image with a solid color.
std::vector< uint8_t > GetImageDataRGBA() const
Gets raw image data in RGBA format.
unsigned int GetHeight() const
Returns the image height.
void WritePngFile(char const *filename)
Writes the image data to a PNG file.
void WriteJpegFile(char const *filename)
Writes the image data to a JPEG file.
const Color GetPixel(unsigned int x, unsigned int y) const
Retrieves the color of a specific pixel.
TEST(ImageDataTests, PixelAssignment)
Represents a color with red, green, blue, and alpha channels.