Skip to content

Commit 707414f

Browse files
committed
Ensure drops don't close unrelated objects
1 parent def3dbf commit 707414f

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

src/hl/file.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ pub mod tests {
516516
assert!(crate::handle::refcount(fileid).is_err());
517517
assert!(crate::handle::refcount(groupid).is_err());
518518
assert!(!group.is_valid());
519+
drop(group);
519520
});
520521
});
521522
}

src/hl/group.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,9 @@ pub mod tests {
229229
h5lock!({
230230
file.close().unwrap();
231231
assert_eq!(format!("{:?}", a), "<HDF5 group: invalid id>");
232+
drop(a);
233+
drop(ab);
234+
drop(abc);
232235
})
233236
})
234237
}

src/hl/object.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,14 @@ pub mod tests {
114114
obj.decref();
115115
assert_eq!(obj.refcount(), 1);
116116
obj.decref();
117-
obj.decref();
118-
assert_eq!(obj.refcount(), 0);
119-
assert!(!obj.is_valid());
120-
assert!(!is_valid_user_id(obj.id()));
121-
assert!(!is_valid_id(obj.id()));
117+
h5lock!({
118+
obj.decref();
119+
assert_eq!(obj.refcount(), 0);
120+
assert!(!obj.is_valid());
121+
assert!(!is_valid_user_id(obj.id()));
122+
assert!(!is_valid_id(obj.id()));
123+
drop(obj);
124+
});
122125
}
123126

124127
#[test]
@@ -156,6 +159,8 @@ pub mod tests {
156159
obj.decref();
157160
assert!(!obj.is_valid());
158161
assert!(!obj2.is_valid());
162+
drop(obj);
163+
drop(obj2);
159164
});
160165
}
161166
}

0 commit comments

Comments
 (0)