Skip to content

Commit

Permalink
Add test changing the indent
Browse files Browse the repository at this point in the history
  • Loading branch information
koppor committed Dec 23, 2015
1 parent 951855d commit 854a9d5
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/test/java/net/sf/jabref/bibtex/BibEntryWriterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class BibEntryWriterTest {
public static void setUp() {
Globals.prefs = JabRefPreferences.getInstance();
backup = Globals.prefs;
// ensure BibTeX mode
Globals.prefs.putBoolean(JabRefPreferences.BIBLATEX_MODE, false);
}

@AfterClass
Expand Down Expand Up @@ -329,4 +331,41 @@ public void monthFieldSpecialSyntax() throws IOException {

assertEquals(bibtexEntry, actual);
}

@Test
public void addFieldWithLongerLength() throws IOException {
// @formatter:off
String bibtexEntry = Globals.NEWLINE + Globals.NEWLINE + "@Article{test," + Globals.NEWLINE +
" author = {BlaBla}," + Globals.NEWLINE +
" journal = {International Journal of Something}," + Globals.NEWLINE +
" number = {1}," + Globals.NEWLINE +
" note = {some note}" + Globals.NEWLINE +
"}";
// @formatter:on

// read in bibtex string
ParserResult result = BibtexParser.parse(new StringReader(bibtexEntry));
Collection<BibEntry> entries = result.getDatabase().getEntries();
BibEntry entry = entries.iterator().next();

// modify entry
entry.setField("howpublished", "asdf");

//write out bibtex string
StringWriter stringWriter = new StringWriter();

writer.write(entry, stringWriter);
String actual = stringWriter.toString();

// @formatter:off
String expected = Globals.NEWLINE + Globals.NEWLINE + "@Article{test," + Globals.NEWLINE +
" author = {BlaBla}," + Globals.NEWLINE +
" journal = {International Journal of Something}," + Globals.NEWLINE +
" number = {1}," + Globals.NEWLINE +
" note = {some note}," + Globals.NEWLINE +
" howpublished = {asdf}" + Globals.NEWLINE +
"}";
// @formatter:on
assertEquals(expected, actual);
}
}

0 comments on commit 854a9d5

Please sign in to comment.