Share GDSII reader logic and simplify review output
Share record framing, name decoding, payload validation, array reference decoding, and Arrow cell-header parsing. Accept trailing NUL padding in names and retain located diagnostics for malformed records. Summarize text diffs by cell, layer, and reference target. Show comparison and omission counts before detail. Compact canonical dumps while preserving exact fields and duplicate counts for Git textconv. Simplify hierarchy output and retain per-object evidence in JSON.
This commit is contained in:
parent
d95c378690
commit
15e8a3b7b5
1 changed files with 1717 additions and 828 deletions
|
|
@ -122,11 +122,41 @@ fn aref_pitches_use_wide_coordinate_differences_in_full_reads_and_scans() {
|
|||
|
||||
#[test]
|
||||
fn aref_invalid_counts_and_unrepresentable_pitches_return_errors() {
|
||||
let check_array_error = |bytes: &[u8], message: &str| {
|
||||
let ranges = [(library_header().len() as u64, bytes.len() as u64 - 4)];
|
||||
for result in [
|
||||
read_library(bytes),
|
||||
scan_library(bytes),
|
||||
read_selected_library(bytes, &ranges),
|
||||
] {
|
||||
let (_, error) = result.unwrap_err();
|
||||
assert!(matches!(error, pheon::basic::ErrType::Failed(reason)
|
||||
if reason.contains(message)));
|
||||
}
|
||||
assert!(
|
||||
pheon::review::Document::parse(bytes)
|
||||
.unwrap_err()
|
||||
.contains(message)
|
||||
);
|
||||
};
|
||||
for counts in [[0, 1], [-1, 1], [1, 0], [1, -1]] {
|
||||
let bytes = aref_fixture([0, 0], [10, 0], [0, 10], counts);
|
||||
assert!(read_library(&bytes).is_err());
|
||||
assert!(scan_library(&bytes).is_err());
|
||||
check_array_error(&bytes, "AREF column and row counts must be positive");
|
||||
}
|
||||
|
||||
let mut bytes = aref_fixture([0, 0], [10, 0], [0, 10], [1, 2]);
|
||||
let xy_offset = pheon::review::Document::parse(&bytes)
|
||||
.unwrap()
|
||||
.records
|
||||
.iter()
|
||||
.find(|record| record.tag == records::RTAG_XY)
|
||||
.unwrap()
|
||||
.offset;
|
||||
let mut replacement = Vec::new();
|
||||
record(&mut replacement, records::RTAG_XY, &[0; 16]);
|
||||
bytes.splice(xy_offset..xy_offset + 28, replacement);
|
||||
check_array_error(&bytes, "AREF needs exactly three XY coordinate pairs");
|
||||
|
||||
let bytes = aref_fixture([i32::MIN, 0], [i32::MAX, 0], [i32::MIN, 10], [1, 2]);
|
||||
assert!(read_library(&bytes).is_err());
|
||||
assert!(scan_library(&bytes).is_err());
|
||||
|
|
@ -472,7 +502,7 @@ fn selections_support_subsets_reordering_and_empty_results() {
|
|||
#[test]
|
||||
fn id_tables_preserve_encounter_order_and_selection_local_ids() {
|
||||
let mut bytes = library_header();
|
||||
for (name, layer, datatype) in [("zeta", 9_i16, 4_i16), ("middle", 2, 8), ("alpha", 9, 4)] {
|
||||
for (name, layer, datatype) in [("zeta", 9_i16, 4_i16), ("middle", 2, 8), ("alpha\0", 9, 4)] {
|
||||
record(&mut bytes, records::RTAG_BGNSTR, &[0; 24]);
|
||||
record(&mut bytes, records::RTAG_STRNAME, name.as_bytes());
|
||||
if name == "zeta" {
|
||||
|
|
|
|||
Loading…
Reference in a new issue