Skip to content

Commit f473003

Browse files
pgodwinclaude
andcommitted
test(fs): assert FinderInfo is closest to the header in AppleSingle layout
Pins the third AppleSingle writing convention (after the 4K resource hole and data-fork-last, already asserted): a frequently-read entry (Finder Info) sits nearest the header so the first block read retrieves it. Encoder was already conformant; this locks it against the spec. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent de3ca01 commit f473003

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

core/fs/fork_single_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,21 @@ func TestAppleSingle_ResourceForkIs4KAllocated(t *testing.T) {
115115
// payload in the file.
116116
rOff, _ := entryOffLen(raw, asEntryResourceFork)
117117
dOff, dLen := entryOffLen(raw, asEntryDataFork)
118-
if rOff == 0 || dOff == 0 {
119-
t.Fatal("resource/data entries missing")
118+
fOff, _ := entryOffLen(raw, asEntryFinderInfo)
119+
if rOff == 0 || dOff == 0 || fOff == 0 {
120+
t.Fatal("resource/data/finderinfo entries missing")
120121
}
121122
if dOff != rOff+asResourceChunk {
122123
t.Fatalf("data fork at %d, want resource(%d)+4K=%d (4K hole not honoured)", dOff, rOff, rOff+asResourceChunk)
123124
}
124125
if int(dOff)+int(dLen) != len(raw) {
125126
t.Fatalf("data fork not last: ends at %d, file len %d", int(dOff)+int(dLen), len(raw))
126127
}
128+
// FinderInfo (a frequently-read entry) sits closest to the header — its payload
129+
// starts immediately after the entry descriptors, before resource and data.
130+
if fOff >= rOff || fOff >= dOff {
131+
t.Fatalf("FinderInfo at %d not closest to header (resource %d, data %d)", fOff, rOff, dOff)
132+
}
127133
}
128134

129135
// TestMacBinary_RoundTrip proves the MacBinary engine round-trips both forks and the

0 commit comments

Comments
 (0)