-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Documentation] information CWE-120: The product copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow. fix: typo on input_output.h fix: delete windows test chore: adding ``input_output_testing`` [Documentation] adding unitesting using google test framwork to test the functionallity of the `save` and `load` function from `clara` library `input_output` Signed-off-by: slowy07 <[email protected]>
- Loading branch information
Showing
3 changed files
with
44 additions
and
37 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include <fstream> | ||
|
||
#include "../../include/clara.h" | ||
#include "../../include/input_output.h" | ||
#include "gtest/gtest.h" | ||
|
||
using namespace clara; | ||
|
||
class InputOutputTest : public ::testing::Test { | ||
protected: | ||
void SetUp() override {} | ||
void TearDown() override {} | ||
}; | ||
|
||
TEST_F(InputOutputTest, SaveAndLoadEigenMatrix) { | ||
Eigen::MatrixXd mat(3, 3); | ||
mat << 1, 2, 3, 4, 5, 6, 7, 8, 9; | ||
|
||
const std::string filename = "test_matrix.bin"; | ||
clara::save(mat, filename); | ||
|
||
auto loadedMatrix = clara::load<Eigen::MatrixXd>(filename); | ||
|
||
ASSERT_EQ(mat.rows(), loadedMatrix.rows()); | ||
ASSERT_EQ(mat.cols(), loadedMatrix.cols()); | ||
|
||
for (int i = 0; i < mat.rows(); ++i) { | ||
for (int j = 0; j < mat.cols(); ++j) { | ||
ASSERT_DOUBLE_EQ(mat(i, j), loadedMatrix(i, j)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters