// // WordBoundaryTruncationTests.swift // Museion // // Round-5 (mercury#4/sol#8/argon#16) → Round-6 glyph-measured // (mercury#4/sol#9) → Round-7 middle-eliding (argon#14/sol#32/47) → // Round-8 head-biased split (sol#3): the roster title's truncation // seam. The r7 split kept only the "Pass N ·" label and maximized the // suffix — the unique head (the topic) died at the same elision point // as before; the seam now grows the head into ~60% of the glyph budget // (label + leading words) and fits the longest suffix in what remains. // Pins: short-string passthrough, the mid-word head cut landing at a // word edge, and the exact strings for the two live Handoff roster // titles. // import CoreGraphics import Foundation @testable import Museion import Testing @Suite("WordBoundaryTruncationTests") struct WordBoundaryTruncationTests { @Test func `short string passes through`() { #expect(WordBoundaryTruncation.fit("Brainstorm", maxWidth: 192) == "Brainstorm") #expect(WordBoundaryTruncation.fit("Pass 1 · The expected value of showing up", maxWidth: 192) == "Pass 1 · The expected value of showing up") #expect(WordBoundaryTruncation.fit("", maxWidth: 192) == "") } @Test func `mid word cut lands at word boundary`() { // The native cut rendered "Markdo…" — with no suffix fitting // beside the head, the head truncates at its word edge. let out = WordBoundaryTruncation.fit("Markdown Notes", maxWidth: 80, lines: 1) #expect(out == "Markdown…") #expect(!out.hasSuffix("Markdo…")) } @Test func `handoff titles split head biased`() { // Round-7 (argon#14/sol#32/47): the two live Handoff roster // titles died at the shared "Reading-Mode Pivot:…" boilerplate — // the distinguishing tail never rendered. Round-8 (sol#3): the // split biases toward the TOPIC — the head keeps the label plus // the leading words ("Museion Handoff —", ~60% of the glyph // budget, measured serif-13 semibold against the roster's 192pt // two-line width); the shared tail shrinks to the longest suffix // that still fits ("apex) vs. Hand-rolled TextKit" — r7's was // the full "→ HTML (+ apex) vs. Hand-rolled TextKit"). let pass2 = "Pass 2 · Museion Handoff — Reading-Mode Pivot: Markdown → HTML (+ apex) vs. Hand-rolled TextKit" let pass1 = "Pass 1 · Museion Handoff — Reading-Mode Pivot: Markdown → HTML (+ apex) vs. Hand-rolled TextKit" #expect(WordBoundaryTruncation.fit(pass2, maxWidth: 192, lines: 2) == "Pass 2 · Museion Handoff — … apex) vs. Hand-rolled TextKit") #expect(WordBoundaryTruncation.fit(pass1, maxWidth: 192, lines: 2) == "Pass 1 · Museion Handoff — … apex) vs. Hand-rolled TextKit") } }