Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add and extend unit tests #7685

Merged
merged 8 commits into from
May 6, 2021
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,30 @@
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, String errorMessage) {
koppor marked this conversation as resolved.
Show resolved Hide resolved
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"))}", "Valid citation key"));
}
}