Skip to content

Commit

Permalink
Add test for correct parsing and serialization of month field special…
Browse files Browse the repository at this point in the history
… syntax
  • Loading branch information
lenhard committed Oct 27, 2015
1 parent 834f37c commit eaf1b52
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/test/java/net/sf/jabref/bibtex/BibtexEntryWriterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,33 @@ public void roundTripTest() throws IOException {

assertEquals(bibtexEntry, actual);
}

@Test
public void monthFieldSpecialSyntax() throws IOException {
String bibtexEntry = "@Article{test," + Globals.NEWLINE +
" Author = {Foo Bar}," + Globals.NEWLINE +
" Month = mar," + Globals.NEWLINE +
" Number = {1}" + Globals.NEWLINE +
"}" + Globals.NEWLINE;

// read in bibtex string
ParserResult result = BibtexParser.parse(new StringReader(bibtexEntry));

Collection<BibtexEntry> entries = result.getDatabase().getEntries();
Assert.assertEquals(1, entries.size());

BibtexEntry entry = entries.iterator().next();
Assert.assertEquals("test", entry.getCiteKey());
Assert.assertEquals(4, entry.getAllFields().size());
Set<String> fields = entry.getAllFields();
Assert.assertTrue(fields.contains("month"));
Assert.assertEquals("#mar#", entry.getField("month"));

//write out bibtex string
StringWriter stringWriter = new StringWriter();
writer.write(entry, stringWriter);
String actual = stringWriter.toString();

assertEquals(bibtexEntry, actual);
}
}

0 comments on commit eaf1b52

Please sign in to comment.