Skip to content

Commit 1f823d5

Browse files
committed
Add a test for Clone (for groups)
1 parent f71e74c commit 1f823d5

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

hdf5-rs/src/hl/group.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,25 @@ pub mod tests {
199199
})
200200
}
201201

202+
#[test]
203+
pub fn test_clone() {
204+
with_tmp_file(|file| {
205+
file.create_group("a").unwrap();
206+
let a = file.group("a").unwrap();
207+
assert_eq!(a.name(), "/a");
208+
assert_eq!(a.file().unwrap().id(), file.id());
209+
assert_eq!(a.refcount(), 1);
210+
let b = a.clone();
211+
assert_eq!(b.name(), "/a");
212+
assert_eq!(b.file().unwrap().id(), file.id());
213+
assert_eq!(b.refcount(), 2);
214+
assert_eq!(a.refcount(), 2);
215+
drop(a);
216+
assert_eq!(b.refcount(), 1);
217+
assert!(b.is_valid());
218+
})
219+
}
220+
202221
#[test]
203222
pub fn test_len() {
204223
with_tmp_file(|file| {

0 commit comments

Comments
 (0)