Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,32 @@ public void insert_final_newline() throws IOException {
PropertyType.insert_final_newline.getName(), "true"));
}

@Test
public void insert_final_newline_system_eol() throws IOException {
final ResourceProperties props = ResourceProperties.builder() //
.property(new Property.Builder(null).type(PropertyType.insert_final_newline).value("true").build()) //
.property(new Property.Builder(null).type(PropertyType.trim_trailing_whitespace).value("true").build()) //
.build();
String text =
"line 1" + System.lineSeparator() + //
"line 2 " + System.lineSeparator() + //
"line 3"//
;
String expectedText =
"line 1" + System.lineSeparator() + //
"line 2" + System.lineSeparator() + //
"line 3" + System.lineSeparator() //
;
Resource doc = LinterTestUtils.createDocument(text, ".txt");

LinterTestUtils.assertParse(linter, doc, expectedText, props, //
new Violation(doc, new Location(2, 7), new Delete(4), linter,
PropertyType.trim_trailing_whitespace.getName(), "true"),
new Violation(doc, new Location(3, 7),
Insert.endOfLine(EndOfLineValue.ofEndOfLineString(System.lineSeparator())), linter,
PropertyType.insert_final_newline.getName(), "true"));
}

@Test
public void insert_final_newline_empty() throws IOException {
final ResourceProperties props = ResourceProperties.builder() //
Expand Down