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 simple unit tests #7696

Merged
merged 3 commits into from
May 13, 2021
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -29,6 +29,11 @@ void extractURLFormLink() {
formatter.format("away.php?to=http%3A%2F%2Fwikipedia.org&a=snippet"));
}

@Test
void validUrlUnmodified() {
assertEquals("http://wikipedia.org", formatter.format("http://wikipedia.org"));
}

@Test
void latexCommandsNotRemoved() {
assertEquals("http://pi.informatik.uni-siegen.de/stt/36\\_2/./03\\_Technische\\_Beitraege/ZEUS2016/beitrag\\_2.pdf", formatter.format("http://pi.informatik.uni-siegen.de/stt/36\\_2/./03\\_Technische\\_Beitraege/ZEUS2016/beitrag\\_2.pdf"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ public void removeHyphensBeforeNewlines() {
assertEquals("water", formatter.format("wa-\rter"));
}

@Test
public void withoutHyphensUnmodified() {
assertEquals("water", formatter.format("water"));
}

@Test
public void removeHyphensBeforePlatformSpecificNewlines() {
String newLine = String.format("%n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ public void removeLineFeed() {
assertEquals("n linebreak", formatter.format("n\nlinebreak"));
}

@Test
public void withoutNewLineUnmodified() {
assertEquals("no linebreak", formatter.format("no linebreak"));
}

@Test
public void removePlatformSpecificNewLine() {
String newLine = String.format("%n");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package org.jabref.logic.formatter.casechanger;

import java.util.stream.Stream;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
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;

Expand All @@ -17,11 +22,19 @@ public void setUp() {
formatter = new LowerCaseFormatter();
}

@Test
public void test() {
assertEquals("lower", formatter.format("LOWER"));
assertEquals("lower {UPPER}", formatter.format("LOWER {UPPER}"));
assertEquals("lower {U}pper", formatter.format("LOWER {U}PPER"));
@ParameterizedTest
@MethodSource("provideStringsForFormat")
public void test(String expected, String input) {
assertEquals(expected, formatter.format(input));
}

private static Stream<Arguments> provideStringsForFormat() {
return Stream.of(
Arguments.of("lower", "lower"),
Arguments.of("lower", "LOWER"),
Arguments.of("lower {UPPER}", "LOWER {UPPER}"),
Arguments.of("lower {U}pper", "LOWER {U}PPER")
);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,9 @@ public void singleClosingBraceCorrectlyRemoved() throws Exception {
public void bracePairWithEscapedBackslashCorrectlyRemoved() throws Exception {
assertEquals("\\some text\\", formatter.format("\\{some text\\}"));
}

@Test
public void withoutBracketsUnmodified() throws Exception {
assertEquals("some text", formatter.format("some text"));
}
}