Merge branch 'feat/p2-writer-groups-links' into feat/p2-perf-coverage
# Conflicts: # CHANGELOG.md # crates/clawhdf5-tools/tests/h5rs_interop.rs
This commit is contained in:
@@ -528,33 +528,50 @@ fn h5py_reads_all_attributes_next_to_an_empty_string() {
|
||||
// ---- 6. path-like names ----
|
||||
|
||||
#[test]
|
||||
fn slash_in_a_group_or_dataset_name_is_an_error() {
|
||||
// Measured: create_group("a/b") wrote one link literally named "a/b",
|
||||
// which h5py cannot reach ("component not found"). The writer has no
|
||||
// nested groups, so such names are refused.
|
||||
fn path_names_create_nested_groups() {
|
||||
// create_group("a/b") used to write one link literally named "a/b",
|
||||
// which h5py cannot reach ("component not found"); then such names were
|
||||
// refused. Now a path creates its missing intermediate groups, as h5py
|
||||
// does.
|
||||
let mut fw = FileWriter::new();
|
||||
let mut g = fw.create_group("a/b");
|
||||
g.create_dataset("c").with_f64_data(&[1.0]);
|
||||
fw.add_group(g.finish());
|
||||
assert!(fw.finish().is_err());
|
||||
|
||||
let mut fw = FileWriter::new();
|
||||
fw.create_dataset("x/y").with_f64_data(&[1.0]);
|
||||
assert!(fw.finish().is_err());
|
||||
|
||||
let mut fw = FileWriter::new();
|
||||
fw.create_dataset("x/y").with_f64_data(&[2.0]);
|
||||
fw.create_dataset("/a/b/z").with_f64_data(&[3.0]);
|
||||
let mut g = fw.create_group("g");
|
||||
g.create_dataset("x/y").with_f64_data(&[1.0]);
|
||||
g.create_dataset("x/y").with_f64_data(&[4.0]);
|
||||
fw.add_group(g.finish());
|
||||
assert!(fw.finish().is_err());
|
||||
let bytes = fw.finish().unwrap();
|
||||
for path in ["a", "a/b", "a/b/c", "a/b/z", "x", "x/y", "g/x", "g/x/y"] {
|
||||
header_at(&bytes, path);
|
||||
}
|
||||
}
|
||||
|
||||
for bad in ["", "."] {
|
||||
#[test]
|
||||
fn names_that_are_not_valid_link_names_are_errors() {
|
||||
for bad in ["", ".", "a//b", "a/", "a/./b", "/"] {
|
||||
let mut fw = FileWriter::new();
|
||||
fw.create_dataset(bad).with_f64_data(&[1.0]);
|
||||
assert!(fw.finish().is_err(), "{bad:?}");
|
||||
}
|
||||
// An absolute path inside a group, and a name used twice.
|
||||
let mut fw = FileWriter::new();
|
||||
let mut g = fw.create_group("g");
|
||||
g.create_dataset("/x").with_f64_data(&[1.0]);
|
||||
fw.add_group(g.finish());
|
||||
assert!(fw.finish().is_err());
|
||||
let mut fw = FileWriter::new();
|
||||
fw.create_dataset("x").with_f64_data(&[1.0]);
|
||||
fw.create_dataset("x").with_f64_data(&[1.0]);
|
||||
assert!(fw.finish().is_err());
|
||||
// A dataset in the way of a path.
|
||||
let mut fw = FileWriter::new();
|
||||
fw.create_dataset("x").with_f64_data(&[1.0]);
|
||||
fw.create_dataset("x/y").with_f64_data(&[1.0]);
|
||||
assert!(fw.finish().is_err());
|
||||
|
||||
// One level of groups still works, and '/' stays legal in attribute names.
|
||||
// '/' stays legal in attribute names.
|
||||
let mut fw = FileWriter::new();
|
||||
let mut g = fw.create_group("g");
|
||||
g.create_dataset("c").with_f64_data(&[1.0]);
|
||||
|
||||
Reference in New Issue
Block a user