Fix Logger and other build issues #7
@@ -52,6 +52,11 @@ bool Bitmap<T>::setPixels(const std::vector<T>& pixels) {
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
std::vector<T> Bitmap<T>::getPixelsCpy() {
|
||||
return mPixels;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
std::optional<std::vector<T>> Bitmap<T>::getLine(uint16_t line) {
|
||||
if (line >= mHeight) {
|
||||
|
@@ -22,6 +22,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
@@ -41,6 +42,7 @@ class Bitmap {
|
||||
uint16_t getWidth();
|
||||
uint16_t getHeight();
|
||||
bool setPixels(const std::vector<T>& pixels);
|
||||
std::vector<T> getPixelsCpy();
|
||||
std::optional<std::vector<T>> getLine(uint16_t line);
|
||||
std::optional<std::vector<T>> getCol(uint16_t col);
|
||||
|
||||
|
@@ -21,7 +21,9 @@
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
TEST(basic_test, Bitmap_createBitmapWithCertainSize_yieldsSpecifiedSize) {
|
||||
auto bm = ptprnt::graphics::Bitmap<ptprnt::graphics::ALPHA8>(16, 8);
|
||||
@@ -64,3 +66,36 @@ TEST(basic_test, Bitmap_getBitmapColInsideOfImage_yieldsValidColSize) {
|
||||
auto colSize = col->size();
|
||||
ASSERT_EQ(8, colSize);
|
||||
}
|
||||
|
||||
TEST(basic_test, Bitmap_setPixels_setsGivenPixels) {
|
||||
auto bm = ptprnt::graphics::Bitmap<ptprnt::graphics::ALPHA8>(16, 8);
|
||||
std::vector<uint8_t> pix(16 * 8);
|
||||
|
||||
bm.setPixels(pix);
|
||||
auto pixCpy = bm.getPixelsCpy();
|
||||
|
||||
ASSERT_EQ(pix, pixCpy);
|
||||
}
|
||||
|
||||
TEST(basic_test, Bitmap_setPixels_isSuccessfulWithValidPixels) {
|
||||
auto bm = ptprnt::graphics::Bitmap<ptprnt::graphics::ALPHA8>(16, 8);
|
||||
std::vector<uint8_t> pix(16 * 8);
|
||||
|
||||
ASSERT_TRUE(bm.setPixels(pix));
|
||||
}
|
||||
|
||||
TEST(basic_test, Bitmap_setPixels_yieldsSamePixelsBack) {
|
||||
auto bm = ptprnt::graphics::Bitmap<ptprnt::graphics::ALPHA8>(16, 8);
|
||||
std::vector<uint8_t> pix(16 * 8);
|
||||
|
||||
bm.setPixels(pix);
|
||||
auto pixCpy = bm.getPixelsCpy();
|
||||
ASSERT_EQ(pix, pixCpy);
|
||||
}
|
||||
|
||||
TEST(basic_test, Bitmap_setPixelsWithWrongSize_isFailing) {
|
||||
auto bm = ptprnt::graphics::Bitmap<ptprnt::graphics::ALPHA8>(5, 8);
|
||||
std::vector<uint8_t> pix(16 * 8);
|
||||
|
||||
ASSERT_FALSE(bm.setPixels(pix));
|
||||
}
|
||||
|
Reference in New Issue
Block a user