From a9d15fa3ae7dbacc16f41fb81418617db88a164f Mon Sep 17 00:00:00 2001 From: Leo Galambos Date: Mon, 20 Apr 2026 00:08:07 +0200 Subject: [PATCH] test: add regression coverage for trailing SKIP omission in patch encoding --- .../egothor/stemmer/PatchCommandEncoderTest.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/java/org/egothor/stemmer/PatchCommandEncoderTest.java b/src/test/java/org/egothor/stemmer/PatchCommandEncoderTest.java index cff44eb..4f91a41 100644 --- a/src/test/java/org/egothor/stemmer/PatchCommandEncoderTest.java +++ b/src/test/java/org/egothor/stemmer/PatchCommandEncoderTest.java @@ -313,6 +313,22 @@ class PatchCommandEncoderTest { @Tag("encode") class EncodeTests { + /** + * Verifies that trailing SKIP instructions are omitted from the generated patch + * command because they do not affect reconstruction. + */ + @Test + @DisplayName("does not emit trailing SKIP instructions into patch command") + void shouldNotEmitTrailingSkipInstructionsIntoPatchCommand() { + PatchCommandEncoder encoder = new PatchCommandEncoder(); + + String patch = encoder.encode("abcd", "ab"); + + assertAll(() -> assertNotNull(patch), () -> assertEquals("Db", patch), + () -> assertEquals("ab", PatchCommandEncoder.apply("abcd", patch)), () -> assertEquals(-1, + patch.indexOf('-'), () -> "Patch must not contain a trailing SKIP instruction: " + patch)); + } + /** * Verifies that a null source yields a null patch. */