brodcasting test hinzugefügt
This commit is contained in:
parent
f8035cc4db
commit
34a471bda6
@ -141,6 +141,32 @@ void test_setMatrixAtFailsOnIndicesOutOfRange(void)
|
|||||||
TEST_ASSERT_EQUAL_FLOAT_ARRAY(expectedResults, matrixToTest.buffer, matrixToTest.cols * matrixToTest.rows);
|
TEST_ASSERT_EQUAL_FLOAT_ARRAY(expectedResults, matrixToTest.buffer, matrixToTest.cols * matrixToTest.rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_addSupportsBroadcasting(void)
|
||||||
|
{
|
||||||
|
MatrixType buffer1[] = {1, 2, 3, 4, 5, 6};
|
||||||
|
MatrixType buffer2[] = {7, 8};
|
||||||
|
Matrix matrix1 = {.rows=2, .cols=3, .buffer=buffer1};
|
||||||
|
Matrix matrix2 = {.rows=2, .cols=1, .buffer=buffer2};
|
||||||
|
|
||||||
|
Matrix result1 = add(matrix1, matrix2);
|
||||||
|
Matrix result2 = add(matrix2, matrix1);
|
||||||
|
|
||||||
|
float expectedResults[] = {8, 9, 10, 12, 13, 14};
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL_UINT32(matrix1.rows, result1.rows);
|
||||||
|
TEST_ASSERT_EQUAL_UINT32(matrix1.cols, result1.cols);
|
||||||
|
TEST_ASSERT_EQUAL_UINT32(matrix1.rows, result2.rows);
|
||||||
|
TEST_ASSERT_EQUAL_UINT32(matrix1.cols, result2.cols);
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL_INT(sizeof(expectedResults)/sizeof(expectedResults[0]), result1.rows * result1.cols);
|
||||||
|
TEST_ASSERT_EQUAL_FLOAT_ARRAY(expectedResults, result1.buffer, result1.cols * result1.rows);
|
||||||
|
TEST_ASSERT_EQUAL_INT(sizeof(expectedResults)/sizeof(expectedResults[0]), result2.rows * result2.cols);
|
||||||
|
TEST_ASSERT_EQUAL_FLOAT_ARRAY(expectedResults, result2.buffer, result2.cols * result2.rows);
|
||||||
|
|
||||||
|
free(result1.buffer);
|
||||||
|
free(result2.buffer);
|
||||||
|
}
|
||||||
|
|
||||||
void setUp(void) {
|
void setUp(void) {
|
||||||
// Falls notwendig, kann hier Vorbereitungsarbeit gemacht werden
|
// Falls notwendig, kann hier Vorbereitungsarbeit gemacht werden
|
||||||
}
|
}
|
||||||
@ -165,6 +191,7 @@ int main()
|
|||||||
RUN_TEST(test_getMatrixAtFailsOnIndicesOutOfRange);
|
RUN_TEST(test_getMatrixAtFailsOnIndicesOutOfRange);
|
||||||
RUN_TEST(test_setMatrixAtSetsCorrectValue);
|
RUN_TEST(test_setMatrixAtSetsCorrectValue);
|
||||||
RUN_TEST(test_setMatrixAtFailsOnIndicesOutOfRange);
|
RUN_TEST(test_setMatrixAtFailsOnIndicesOutOfRange);
|
||||||
|
RUN_TEST(test_addSupportsBroadcasting);
|
||||||
|
|
||||||
return UNITY_END();
|
return UNITY_END();
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user