Skip to content

test: pin round-trip integrity, UUID-derived UIDs, and UN padding behavior - #525

Merged
awatson1978 merged 1 commit into
release/1.0-beta-corefrom
core/bank-roundtrip
Sep 29, 2026
Merged

awatson1978 merged 1 commit into
release/1.0-beta-corefrom
core/bank-roundtrip

Conversation

@awatson1978

@awatson1978 awatson1978 commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

This is the second batch of the regression bank for the 1.0 branch: test suites that pin behavior the current code already gets right, with the known-broken parts checked in as it.skip entries that name the issue they're waiting on. The suites arrive green, and later engine work flips the skips one issue at a time instead of rediscovering old bugs.

Three suites here, all derived from upstream issue reports, all running on synthetic in-memory files (no fixtures needed).

test/issues/issue111-roundtrip-integrity.test.js is the big one. It pins the read → naturalize → denaturalize → write → read round trip on synthetic multiframe files, in both plain and encapsulated (fragment-list) variants. "Naturalize" is the conversion from the raw tag dictionary to the friendly keyword-named JavaScript object, and denaturalize is the way back. Six upstream reports live in this suite: #111 (the round trip produced a broken image), #115 (PixelRepresentation with value 0 — a falsy number — was dropped), #95 (a same-length PatientName edit corrupted the pixel bytes), #167 (repeated read/write cycles grew the file without bound until it ran out of memory), #418 (a zero-length element was silently omitted, changing the element set), and #458/#466 (a lenient write option silently lost pixel data, and the output made DCMTK error out downstream).

Here's the #167 pin, representative of the style:

it("plain multiframe: output size stabilizes (cycle 2 === cycle 3)", () => {
    const buffer = makePlainBuffer();
    const sizes = cycleSizes(buffer); // read → write, three times
    expect(sizes[1]).toBe(sizes[2]);
    // no unbounded growth: even cycle 3 stays within 2x the source
    expect(sizes[2]).toBeLessThan(buffer.byteLength * 2);
});

test/issues/issue61-uuid-uids.test.js covers UID generation. The standard says a UID rooted at "2.25" must be the decimal encoding of a 128-bit UUID. The current generator just concatenates 39 random digits, and that integer is usually too large to correspond to any UUID at all. The green tests pin the syntax the generator does satisfy: starts with "2.25.", 64 characters max, digits only, no leading zero. The UUID-derivation requirement itself is the suite's it.skip, labeled KNOWN GAP #61.

test/issues/issue52-un-padding.test.js settles an old padding question. UN is the "unknown" value representation, and DICOM requires every value to occupy an even number of bytes, so odd-length values get one pad byte. The #52 reporter read the 2013 standard as forbidding a NUL pad for UN, but the current edition explicitly pads UN with a trailing NUL byte, like OB. So this suite pins NUL-padding to an even declared length as the deliberate, standard-conformant contract — no skips here.

Merging this only adds tests. Everything unskipped passes on this branch as-is, and the one skipped gap (#61) stays on the record with its issue number until the engine-fix PR flips it.

🤖 Generated with Claude Code

@awatson1978
awatson1978 merged commit ebe0416 into release/1.0-beta-core Sep 29, 2026
8 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.0.0-beta.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant