我正在尝试创建运行测试所需的字符串数组。我就是这么做的。在googletest框架中的for循环中运行EXPECT_THROWD
TEST(ParseTest, UnknownType) {
String test_strings[] = {
String("X 1024\n"),
String("AB 1024\n")
};
int test_strings_size = sizeof(test_strings)/sizeof(test_strings[0]);
for (int idx = 0; idx < test_strings_size; idx++) {
Transaction transaction;
String transaction_type = test_strings[idx];
EXPECT_THROW(transaction.parse(transaction_type), ParseError);
}
}
但是,当我在谷歌测试框架运行它,我得到以下错误:
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from ParseTest
[ RUN ] ParseTest.UnknownRequestType
tests/transaction.cpp:20: Failure
Expected: transaction.parse(transaction_type) throws an exception of type ParseError.
Actual: it throws nothing.
[ FAILED ] ParseTest.UnknownRequestType (0 ms)
[----------] 1 test from ParseTest (0 ms total)
[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (0 ms total)
[ PASSED ] 0 tests.
[ FAILED ] 1 test, listed below:
[ FAILED ] ParseTest.UnknownRequestType
1 FAILED TEST
当这应该实际运行两个测试用例,它抱怨的只有一个。我错过了什么吗?