diff --git a/src/test/java/org/jabref/logic/formatter/bibtexfields/AddBracesFormatterTest.java b/src/test/java/org/jabref/logic/formatter/bibtexfields/AddBracesFormatterTest.java index 85b6ef5003e..e2003e25034 100644 --- a/src/test/java/org/jabref/logic/formatter/bibtexfields/AddBracesFormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/bibtexfields/AddBracesFormatterTest.java @@ -72,4 +72,9 @@ public void formatDoesNotRemoveBracesInBrokenString() { public void formatExample() { assertEquals("{In CDMA}", formatter.format(formatter.getExampleInput())); } + + @Test + public void formatStringWithMinimalRequiredLength() { + assertEquals("{AB}", formatter.format("AB")); + } } diff --git a/src/test/java/org/jabref/logic/formatter/bibtexfields/NormalizePagesFormatterTest.java b/src/test/java/org/jabref/logic/formatter/bibtexfields/NormalizePagesFormatterTest.java index 1281c8a5202..f1dd4241bd3 100644 --- a/src/test/java/org/jabref/logic/formatter/bibtexfields/NormalizePagesFormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/bibtexfields/NormalizePagesFormatterTest.java @@ -62,6 +62,7 @@ private static Stream tests() { // special case, where -- is also put into Arguments.of("some--text", "some-text"), Arguments.of("pages 1--50", "pages 1-50"), + Arguments.of("--43", "-43"), // keep arbitrary text Arguments.of("some-text-with-dashes", "some-text-with-dashes"), diff --git a/src/test/java/org/jabref/logic/integrity/ValidCitationKeyCheckerTest.java b/src/test/java/org/jabref/logic/integrity/ValidCitationKeyCheckerTest.java new file mode 100644 index 00000000000..042672a4430 --- /dev/null +++ b/src/test/java/org/jabref/logic/integrity/ValidCitationKeyCheckerTest.java @@ -0,0 +1,31 @@ +package org.jabref.logic.integrity; + +import java.util.Optional; +import java.util.stream.Stream; + +import org.jabref.logic.l10n.Localization; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class ValidCitationKeyCheckerTest { + + private final ValidCitationKeyChecker checker = new ValidCitationKeyChecker(); + + @ParameterizedTest + @MethodSource("provideCitationKeys") + void citationKeyValidity(Optional optionalArgument, String citationKey) { + assertEquals(optionalArgument, checker.checkValue(citationKey)); + } + + private static Stream provideCitationKeys() { + return Stream.of( + Arguments.of(Optional.of(Localization.lang("empty citation key")), ""), + Arguments.of(Optional.empty(), "Seaver2019"), + Arguments.of(Optional.of(Localization.lang("Invalid citation key")), "Seaver_2019}") + ); + } +}