I have the following function:
unsigned* b_row_to_array(b_row r) {
unsigned a[] = {(r >> 8) & 3,
(r >> 6) & 3,
(r >> 4) & 3,
(r >> 2) & 3,
r & 3};
return a;
}
That I wrote the following test function for:
TEST_METHOD(BRowToArrayTest) {
unsigned expected[] = { 0, 0, 0, 0, 0 };
unsigned* computed = b_row_to_array(0);
for (int i = 0; i < 1; i++) {
Assert::AreEqual(expected[i], computed[i]);
}
}
But the test fails, saying "Expected:<0>, Actual:<42348989>", where the value for Actual is different with every test, so it must be reading in the wrong address. Am I using pointers wrong or does it read out-of-bounds because the test function is not in the same project? How can I solve this?