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. */