Skip to content

Commit

Permalink
add and extend unit tests (#7685)
Browse files Browse the repository at this point in the history
  • Loading branch information
BShaq authored May 6, 2021
1 parent 9dfd409 commit d9964c6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ private static Stream<Arguments> 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"),
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Arguments> 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}")
);
}
}

0 comments on commit d9964c6

Please sign in to comment.