Unified Diff - CRLF Line Endings Throughout
Byte-for-byte the same diff as its LF twin except that every line ends CR LF, which is what a diff produced or saved on Windows looks like. Readers that compare a hunk line against expected content without stripping the CR find that no line matches.
--- a/internal/ledger/apply.go 2026-03-02 09:14:03.000000000 +0000
+++ b/internal/ledger/apply.go 2026-03-02 10:41:55.000000000 +0000
@@ -1,14 +1,21 @@
package ledger
-import "errors"
+import (
+ "errors"
+ "fmt"
+)
// ErrShortBalance is returned when a posting would drive the balance negative.
var ErrShortBalance = errors.New("ledger: insufficient balance")
// Apply posts one delta against the running balance and returns the new total.
+// A zero delta is a no-op and never reports an error.
func Apply(balance, delta int64) (int64, error) {
+ if delta == 0 {
+ return balance, nil
+ }
if balance+delta < 0 {
- return balance, ErrShortBalance
+ return balance, fmt.Errorf("%w: balance %d, requested %d", ErrShortBalance, balance, delta)
}
return balance + delta, nil
}
Specifications
- Seed
- 20260807
- Diff Format
- unified
- Files
- 1
- Line Endings
- CRLF
- Encoding
- UTF-8
- Twin
- LF
Testing contract
Expected to pass- Scenario
- Apply a CRLF-terminated patch file to an LF-terminated working tree.
- Expected result
- Applying succeeds after the CR is stripped from the patch's own line endings; the patched file keeps LF endings and matches the LF twin's result exactly.
What is a .diff file?
A .diff file records the difference between two versions of one or more text files. The unified format — the default almost everywhere — names the old and new files on `---` and `+++` lines, then lists hunks introduced by `@@ -old,count +new,count @@` in which context lines are unprefixed and changed lines are prefixed with `-` or `+`. Older context and normal diff formats exist but are rarely produced today.
How to use this file
Use an example .diff file to test diff parsers, syntax highlighters, and merge tooling — verifying hunk-offset arithmetic, correct handling of context lines that begin with a space, and behaviour on files whose changes include trailing-whitespace or line-ending differences.
How to use this file for testing
“Unified Diff - CRLF Line Endings Throughout” is a deterministic Novus Examples fixture for Encoding detection, Visual diff / regression, Editor testing. UTF-8, UTF-8-BOM, UTF-16, and Latin-1 files with documented encodings and line endings for testing charset detection.
Documented properties for this file: seed 20260807 · UTF-8 · CRLF. Compare results against paired or grouped companions on this page when present (clean↔damaged, searchable↔scanned, or format twins) so scores stay reproducible across runs.
Download the file once, keep the path stable in CI or local scripts, and treat the spec table as the contract: dimensions, seeds, field lists, and roles are intentional. Corrupt or invalid samples are labelled as such — expect parsers to fail loudly rather than silently accept them.
Diff and patch fixtures name their target paths and the exact edge case they exercise — rename, mode change, binary hunk, CRLF↔LF, or missing trailing newline. Apply or render them against the documented before-state; every author, path, and hash is fictional.
Related files
- diffUnified Diff - Line-Ending Conversion as Content ChangeThe file itself is LF-terminated, but every removed line carries a literal CR as its last character because the change under review is a CRLF-to-LF conversion. Renderers that do not show the CR display a hunk in which every removed and added line looks identical.

- diffUnified Diff - Octal-Quoted Non-ASCII PathsWith git's default `core.quotepath`, a path containing non-ASCII bytes is wrapped in double quotes and each byte is written as a backslash-octal escape. A parser that takes the header text literally creates a directory called `caf\303\251` on disk.

- diffUnified Diff - Raw UTF-8 Non-ASCII PathsThe same change with `core.quotepath=false`, so the path is written as raw UTF-8 and the header is not quoted. Compare with the quoted twin to confirm a parser resolves both spellings to the same file.

- diffUnified Diff - Bare Line Number in the Hunk HeaderA one-line file changed in place. Both ranges have length one, so the header is written `@@ -1 +1 @@` with no comma and no count — the abbreviation the unified format allows and that regexes of the form `-(\d+),(\d+)` fail to match.

- diffUnified Diff - Deleted File Against /dev/nullThe mirror of the added-file fixture: every line is a deletion and the new range is `+0,0`. A renderer that writes an empty file instead of unlinking it, or that reports the change as a truncation, fails this one.

- diffUnified Diff - Function Heading After the Hunk Headergit appends the enclosing declaration after the closing `@@` of each hunk header. The text is free-form and is not part of the range, so a parser that splits the header on `@@` and takes the last field reads the function signature as a range.

Generated by generation/version_control.py. Free for any use, no attribution required — license.