Skip to content

Commit 3066648

Browse files
fphammerleWanzenBug
authored andcommitted
Revert "replace gtest macro ASSERT_{NO_,}THROW with EXPECT to avoid clang-tidy warning cppcoreguidelines-avoid-goto"
This reverts commit abd0c9d. > tests/HdfFileTest.cpp:16:5: error: avoid using 'goto' for flow control [cppcoreguidelines-avoid-goto,-warnings-as-errors] > EXPECT_NO_THROW(file.get("Data")); > ^
1 parent a1695be commit 3066648

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

.clang-tidy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ WarningsAsErrors: >-
1818
*,
1919
-bugprone-exception-escape,
2020
-clang-diagnostic-return-type,
21+
-cppcoreguidelines-avoid-goto,
2122
-cppcoreguidelines-owning-memory,
2223
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
2324
-cppcoreguidelines-pro-bounds-pointer-arithmetic,

tests/HdfFileTest.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ class HdfFileTest : public ::testing::Test {
1313
};
1414

1515
TEST_F(HdfFileTest, DatasetValidity) {
16-
EXPECT_NO_THROW(file.get("Data"));
16+
ASSERT_NO_THROW(file.get("Data"));
1717
}
1818

1919
TEST_F(HdfFileTest, GroupValidity) {
20-
EXPECT_NO_THROW(file.get("Group"));
20+
ASSERT_NO_THROW(file.get("Group"));
2121
}
2222

2323
TEST_F(HdfFileTest, InvalidItem) {
24-
EXPECT_THROW(file.get("InvalidKey"), HdfException);
24+
ASSERT_THROW(file.get("InvalidKey"), HdfException);
2525
}
2626

2727
TEST_F(HdfFileTest, ReadData1) {
@@ -78,7 +78,7 @@ TEST_F(HdfFileTest, ReadGroupAttributes) {
7878
}
7979

8080
TEST_F(HdfFileTest, ReadInvalidData) {
81-
EXPECT_THROW(file.get("InvalidKey"), HdfException);
81+
ASSERT_THROW(file.get("InvalidKey"), HdfException);
8282
}
8383

8484
TEST_F(HdfFileTest, ReadDataInRange) {
@@ -98,12 +98,12 @@ TEST_F(HdfFileTest, ReadDataInRange) {
9898

9999
TEST_F(HdfFileTest, ReadInvalidDatasetAttribute) {
100100
HdfItem item = file.get("Data");
101-
EXPECT_THROW(HdfAttribute attribute = item.getAttribute("Attribute"), HdfException);
101+
ASSERT_THROW(HdfAttribute attribute = item.getAttribute("Attribute"), HdfException);
102102
}
103103

104104
TEST_F(HdfFileTest, ReadInvalidGroupAttribute) {
105105
HdfItem item = file.get("Group");
106-
EXPECT_THROW(HdfAttribute attribute = item.getAttribute("Attribute"), HdfException);
106+
ASSERT_THROW(HdfAttribute attribute = item.getAttribute("Attribute"), HdfException);
107107
}
108108

109109
TEST_F(HdfFileTest, GetAllDatsetsWithTheSameName) {
@@ -119,21 +119,21 @@ TEST_F(HdfFileTest, GetAllDatsetsWithTheSameName) {
119119
TEST_F(HdfFileTest, DatasetTypeIncompatibility) {
120120
std::vector<std::string> vec;
121121
HdfItem item = file.get("Data");
122-
EXPECT_THROW(item.read(vec), HdfException);
122+
ASSERT_THROW(item.read(vec), HdfException);
123123
}
124124

125125
TEST_F(HdfFileTest, DatasetAttributeTypeIncompatibility) {
126126
std::vector<std::string> vec;
127127
HdfItem item = file.get("DataWithAttributes");
128128
HdfAttribute attribute = item.getAttribute("Integer");
129-
EXPECT_THROW(attribute.get(vec), HdfException);
129+
ASSERT_THROW(attribute.get(vec), HdfException);
130130
}
131131

132132
TEST_F(HdfFileTest, GroupAttributeTypeIncompatibility) {
133133
std::vector<std::string> vec;
134134
HdfItem item = file.get("GroupWithOnlyAttribute");
135135
HdfAttribute attribute = item.getAttribute("Egy");
136-
EXPECT_THROW(attribute.get(vec), HdfException);
136+
ASSERT_THROW(attribute.get(vec), HdfException);
137137
}
138138

139139
TEST_F(HdfFileTest, GlobalAttribute) {
@@ -181,7 +181,7 @@ TEST_F(HdfFileTest, ItemIterator3) {
181181
}
182182

183183
TEST_F(HdfFileTest, HiddenGroup) {
184-
EXPECT_NO_THROW(file.get("RIG0.0"));
184+
ASSERT_NO_THROW(file.get("RIG0.0"));
185185
}
186186

187187
TEST_F(HdfFileTest, VDataRead1) {

0 commit comments

Comments
 (0)