Increase the coverage a bit to see if reporting is motivating :)
All checks were successful
Build ptprnt / build (push) Successful in 1m50s
All checks were successful
Build ptprnt / build (push) Successful in 1m50s
This commit is contained in:
@@ -52,6 +52,11 @@ bool Bitmap<T>::setPixels(const std::vector<T>& pixels) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
std::vector<T> Bitmap<T>::getPixelsCpy() {
|
||||||
|
return mPixels;
|
||||||
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
std::optional<std::vector<T>> Bitmap<T>::getLine(uint16_t line) {
|
std::optional<std::vector<T>> Bitmap<T>::getLine(uint16_t line) {
|
||||||
if (line >= mHeight) {
|
if (line >= mHeight) {
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <memory>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -41,6 +42,7 @@ class Bitmap {
|
|||||||
uint16_t getWidth();
|
uint16_t getWidth();
|
||||||
uint16_t getHeight();
|
uint16_t getHeight();
|
||||||
bool setPixels(const std::vector<T>& pixels);
|
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>> getLine(uint16_t line);
|
||||||
std::optional<std::vector<T>> getCol(uint16_t col);
|
std::optional<std::vector<T>> getCol(uint16_t col);
|
||||||
|
|
||||||
|
@@ -21,7 +21,9 @@
|
|||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
TEST(basic_test, Bitmap_createBitmapWithCertainSize_yieldsSpecifiedSize) {
|
TEST(basic_test, Bitmap_createBitmapWithCertainSize_yieldsSpecifiedSize) {
|
||||||
auto bm = ptprnt::graphics::Bitmap<ptprnt::graphics::ALPHA8>(16, 8);
|
auto bm = ptprnt::graphics::Bitmap<ptprnt::graphics::ALPHA8>(16, 8);
|
||||||
@@ -64,3 +66,36 @@ TEST(basic_test, Bitmap_getBitmapColInsideOfImage_yieldsValidColSize) {
|
|||||||
auto colSize = col->size();
|
auto colSize = col->size();
|
||||||
ASSERT_EQ(8, colSize);
|
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