Problem: I am attempting an assignment that uses GTest as a testing framework. The code defines a "common" file that has exceptions defined in it for the system, which I use in the code as such:
throw ExceptionType::OUT_OF_RANGE;
When running GTest however, I get the following message:
unkown file: Failure
Unkown C++ exception thrown in test body.
My questions are: How would I run gdb with the GTest framework to track down this bug, and it it related to the defined exception within he code or something else.
This is the test in question that is failing:
/** Test that matrix initialization works as expected */
TEST(StarterTest, InitializationTest) {
auto matrix = std::make_unique<RowMatrix<int>>(2, 2);
// Source contains too few elements
std::vector<int> source0(3);
std::iota(source0.begin(), source0.end(), 0);
EXPECT_TRUE(ThrowsBustubException([&]() { matrix->FillFrom(source0); }, ExceptionType::OUT_OF_RANGE));
// Source contains too many elements
std::vector<int> source1(5);
std::iota(source1.begin(), source1.end(), 0);
EXPECT_TRUE(ThrowsBustubException([&]() { matrix->FillFrom(source1); }, ExceptionType::OUT_OF_RANGE));
// Just right
std::vector<int> source2(4);
std::iota(source2.begin(), source2.end(), 0);
EXPECT_NO_THROW(matrix->FillFrom(source2));
for (int i = 0; i < matrix->GetRowCount(); i++) {
for (int j = 0; j < matrix->GetColumnCount(); j++) {
const int expected = (i * matrix->GetColumnCount()) + j;
EXPECT_EQ(expected, matrix->GetElement(i, j));
}
}
}