Skip to content

Commit 19d3e27

Browse files
committed
more test coverage for Group and Node; updates #206'
1 parent 4f3e350 commit 19d3e27

File tree

2 files changed

+30
-13
lines changed

2 files changed

+30
-13
lines changed

src/h5cpp/node/node_view.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ Node NodeView::operator[](const std::string &name) const
8787

8888
}
8989

90-
bool NodeView::exists(const std::string &name,const property::LinkAccessList &lapl) const
90+
bool NodeView::exists(const std::string &name, const property::LinkAccessList &lapl) const
9191
{
9292
//we first have to check whether the link exists
93-
if(!group().links.exists(name))
93+
if(!group().links.exists(name, lapl))
9494
return false;
9595

9696
htri_t result = H5Oexists_by_name(static_cast<hid_t>(group()),

test/node/group_test.cpp

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -112,32 +112,49 @@ TEST_F(GroupTest, test_dataset_creation)
112112
EXPECT_THROW(g.create_dataset("/bad/name", dt, ds), std::runtime_error);
113113
}
114114

115+
TEST_F(GroupTest, test_group_groupview)
116+
{
117+
auto nodes = root_.nodes;
118+
ObjectHandle(static_cast<hid_t>(root_)).close();
119+
EXPECT_THROW(nodes.size(), std::runtime_error);
120+
}
121+
115122
TEST_F(GroupTest, test_group_linkview)
116123
{
117-
node::Group g = file_.root();
118-
EXPECT_FALSE(g.links.exists("group_1"));
124+
property::LinkAccessList lapl;
125+
ObjectHandle(static_cast<hid_t>(lapl)).close();
126+
EXPECT_THROW(root_.links.exists("whatever", lapl), std::runtime_error);
127+
EXPECT_THROW(root_.links.exists("/absolute/path"), std::runtime_error);
128+
EXPECT_THROW(root_.links[99], std::runtime_error);
119129

120-
node::Group g1 = g.create_group("group_1");
121130

122-
EXPECT_TRUE(g.links.exists("group_1"));
131+
EXPECT_FALSE(root_.links.exists("group_1"));
132+
133+
node::Group g1 = root_.create_group("group_1");
134+
135+
EXPECT_TRUE(root_.links.exists("group_1"));
123136

124137
node::Link l;
125-
EXPECT_NO_THROW(l = g.links["group_1"]);
138+
EXPECT_NO_THROW(l = root_.links["group_1"]);
126139
EXPECT_EQ(l, g1.link());
127140
}
128141

129142
TEST_F(GroupTest, test_group_nodeview)
130143
{
131-
node::Group g = file_.root();
144+
EXPECT_THROW(root_.nodes.exists("/absolute/path"), std::runtime_error);
145+
EXPECT_THROW(root_.nodes[99], std::runtime_error);
132146

133-
EXPECT_FALSE(g.nodes.exists("group_1"));
147+
ObjectHandle(static_cast<hid_t>(root_.iterator_config().link_access_list())).close();
148+
EXPECT_THROW(root_.nodes["path"], std::runtime_error);
149+
root_.iterator_config().link_access_list(property::LinkAccessList());
134150

135-
node::Group g1 = g.create_group("group_1");
151+
EXPECT_FALSE(root_.nodes.exists("group_1"));
152+
153+
node::Group g1 = root_.create_group("group_1");
136154

137-
EXPECT_TRUE(g.nodes.exists("group_1"));
155+
EXPECT_TRUE(root_.nodes.exists("group_1"));
138156

139-
node::Group n;
140-
EXPECT_NO_THROW(n = g.nodes["group_1"]);
157+
node::Group n = root_.nodes["group_1"];
141158
EXPECT_EQ(n.id(), g1.id());
142159
}
143160

0 commit comments

Comments
 (0)