mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-23 06:13:34 +08:00
Matrix: add proper print function testing
Before the print function was just implicitly called somewhere and that's why we had 100% line coverage. With this we have actual testing of the functions.
This commit is contained in:
committed by
Julian Kent
parent
b0b7d7229a
commit
33a629105c
+5
-4
@@ -322,18 +322,19 @@ public:
|
||||
const Matrix<Type, M, N> &self = *this;
|
||||
for (size_t i = 0; i < M; i++) {
|
||||
for (size_t j = 0; j < N; j++) {
|
||||
snprintf(buf + strlen(buf), n - strlen(buf), "\t%8.2g", double(self(i, j))); // directly append to the string buffer
|
||||
snprintf(buf + strlen(buf), n - strlen(buf), "\t%8.8g", double(self(i, j))); // directly append to the string buffer
|
||||
}
|
||||
snprintf(buf + strlen(buf), n - strlen(buf), "\n");
|
||||
}
|
||||
}
|
||||
|
||||
void print() const
|
||||
void print(FILE *stream = stdout) const
|
||||
{
|
||||
static const size_t n = 11*N*M + M; // for every entry a tab and 10 digits, for every row a newline
|
||||
// element: tab, point, 8 digits; row: newline; string: \0 end
|
||||
static const size_t n = 10*N*M + M + 1;
|
||||
char * buf = new char[n];
|
||||
write_string(buf, n);
|
||||
printf("%s\n", buf);
|
||||
fprintf(stream, "%s\n", buf);
|
||||
delete[] buf;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user