From 854a9d538f93deb8ba28d2c464aa2751071b1883 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Wed, 23 Dec 2015 09:32:28 +0100 Subject: [PATCH] Add test changing the indent --- .../sf/jabref/bibtex/BibEntryWriterTest.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/test/java/net/sf/jabref/bibtex/BibEntryWriterTest.java b/src/test/java/net/sf/jabref/bibtex/BibEntryWriterTest.java index 9a9d8d1295b..8e41e77998b 100644 --- a/src/test/java/net/sf/jabref/bibtex/BibEntryWriterTest.java +++ b/src/test/java/net/sf/jabref/bibtex/BibEntryWriterTest.java @@ -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 @@ -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 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); + } }