Increase reduce cols tests granularity
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "pivector2d.h"
|
#include "pivector2d.h"
|
||||||
|
|
||||||
int ROWS_COUNT_INIT = 4;
|
int ROWS_COUNT_INIT = 3;
|
||||||
int ROWS_COUNT_INCREASE = 6;
|
int ROWS_COUNT_INCREASE = 4;
|
||||||
int ROWS_COUNT_REDUCE = 2;
|
int ROWS_COUNT_REDUCE = 2;
|
||||||
|
|
||||||
int COLS_COUNT_INIT = 4;
|
int COLS_COUNT_INIT = 3;
|
||||||
int COLS_COUNT_INCREASE = 6;
|
int COLS_COUNT_INCREASE = 4;
|
||||||
int COLS_COUNT_REDUCE = 2;
|
int COLS_COUNT_REDUCE = 2;
|
||||||
|
|
||||||
void assert_fill_with(PIVector2D<int> vec, int rows, int cols) {
|
void assert_fill_with(PIVector2D<int> vec, int rows, int cols) {
|
||||||
@@ -19,6 +19,8 @@ void assert_fill_with(PIVector2D<int> vec, int rows, int cols) {
|
|||||||
|
|
||||||
class Vector2D : public ::testing::Test {
|
class Vector2D : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
|
PIVector2D<int> vec = PIVector2D<int>(ROWS_COUNT_INIT, COLS_COUNT_INIT);
|
||||||
|
|
||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
for (int r = 0; r < ROWS_COUNT_INIT; ++r) {
|
for (int r = 0; r < ROWS_COUNT_INIT; ++r) {
|
||||||
for (int c = 0; c < COLS_COUNT_INIT; ++c) {
|
for (int c = 0; c < COLS_COUNT_INIT; ++c) {
|
||||||
@@ -27,7 +29,26 @@ protected:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PIVector2D<int> vec = PIVector2D<int>(ROWS_COUNT_INIT, COLS_COUNT_INIT);
|
void resize_reduce_is_data_stay_consistent(int newRowsCount, int newColsCount) {
|
||||||
|
piCout << "Before:";
|
||||||
|
piCout << vec;
|
||||||
|
piCout << "";
|
||||||
|
vec.resize(newRowsCount, newColsCount, 0);
|
||||||
|
piCout << "After:";
|
||||||
|
piCout << vec;
|
||||||
|
assert_fill_with(vec, newRowsCount, newColsCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
void resize_increase_is_data_stay_consistent(int newRowsCount, int newColsCount) {
|
||||||
|
vec.resize(newRowsCount, newColsCount, 0);
|
||||||
|
assert_fill_with(vec, ROWS_COUNT_INIT, COLS_COUNT_INIT);
|
||||||
|
|
||||||
|
for (int r = ROWS_COUNT_INIT; r < newRowsCount; ++r) {
|
||||||
|
for (int c = COLS_COUNT_INIT; c < newColsCount; ++c) {
|
||||||
|
ASSERT_EQ(vec.element(r, c), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(Vector2D, resize_is_increase_col_count) {
|
TEST_F(Vector2D, resize_is_increase_col_count) {
|
||||||
@@ -50,17 +71,18 @@ TEST_F(Vector2D, resize_is_reduce_rows_count) {
|
|||||||
ASSERT_EQ(vec.rows(), ROWS_COUNT_REDUCE);
|
ASSERT_EQ(vec.rows(), ROWS_COUNT_REDUCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(Vector2D, resize_increase_is_data_stay_consistent) {
|
TEST_F(Vector2D, resize_increase_both_is_data_stay_consistent) {
|
||||||
vec.resize(ROWS_COUNT_INCREASE, COLS_COUNT_INCREASE, 0);
|
resize_increase_is_data_stay_consistent(ROWS_COUNT_INCREASE, COLS_COUNT_INCREASE);
|
||||||
assert_fill_with(vec, ROWS_COUNT_INIT, COLS_COUNT_INIT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(Vector2D, resize_reduce_is_data_stay_consistent) {
|
TEST_F(Vector2D, resize_reduce_cols_is_data_stay_consistent) {
|
||||||
piCout << "Before:";
|
resize_reduce_is_data_stay_consistent(ROWS_COUNT_INIT, COLS_COUNT_REDUCE);
|
||||||
piCout << vec;
|
}
|
||||||
piCout << "";
|
|
||||||
vec.resize(ROWS_COUNT_REDUCE, COLS_COUNT_REDUCE, 0);
|
TEST_F(Vector2D, resize_reduce_rows_is_data_stay_consistent) {
|
||||||
piCout << "After:";
|
resize_reduce_is_data_stay_consistent(ROWS_COUNT_REDUCE, COLS_COUNT_INIT);
|
||||||
piCout << vec;
|
}
|
||||||
assert_fill_with(vec, ROWS_COUNT_REDUCE, COLS_COUNT_REDUCE);
|
|
||||||
|
TEST_F(Vector2D, resize_reduce_both_is_data_stay_consistent) {
|
||||||
|
resize_reduce_is_data_stay_consistent(ROWS_COUNT_REDUCE, COLS_COUNT_REDUCE);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user