Skip to content
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 @@ -2,6 +2,8 @@

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

import static org.junit.jupiter.api.Assertions.assertEquals;

Expand All @@ -14,11 +16,10 @@ void setUp() {
formatter = new RemoveHyphenatedNewlinesFormatter();
}

@Test
void removeHyphensBeforeNewlines() {
assertEquals("water", formatter.format("wa-\nter"));
assertEquals("water", formatter.format("wa-\r\nter"));
assertEquals("water", formatter.format("wa-\rter"));
@ParameterizedTest
@ValueSource(strings = {"wa-\nter", "wa-\r\nter", "wa-\rter"})
void removeHyphensBeforeNewlines(String expression) {
assertEquals("water", formatter.format(expression));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package org.jabref.logic.formatter.bibtexfields;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

import static org.junit.jupiter.api.Assertions.assertEquals;

Expand All @@ -14,45 +15,39 @@ void setUp() {
formatter = new TrimWhitespaceFormatter();
}

@Test
void removeHorizontalTabulations() {
assertEquals("whitespace", formatter.format("\twhitespace"));
assertEquals("whitespace", formatter.format("whitespace\t"));
assertEquals("whitespace", formatter.format("\twhitespace\t\t"));
}

@Test
void removeLineFeeds() {
assertEquals("whitespace", formatter.format("\nwhitespace"));
assertEquals("whitespace", formatter.format("whitespace\n"));
assertEquals("whitespace", formatter.format("\nwhitespace\n\n"));
}

@Test
void removeFormFeeds() {
assertEquals("whitespace", formatter.format("\fwhitespace"));
assertEquals("whitespace", formatter.format("whitespace\f"));
assertEquals("whitespace", formatter.format("\fwhitespace\f\f"));
}

@Test
void removeCarriageReturnFeeds() {
assertEquals("whitespace", formatter.format("\rwhitespace"));
assertEquals("whitespace", formatter.format("whitespace\r"));
assertEquals("whitespace", formatter.format("\rwhitespace\r\r"));
}

@Test
void removeSeparatorSpaces() {
assertEquals("whitespace", formatter.format(" whitespace"));
assertEquals("whitespace", formatter.format("whitespace "));
assertEquals("whitespace", formatter.format(" whitespace "));
}

@Test
void removeMixedWhitespaceChars() {
assertEquals("whitespace", formatter.format(" \r\t\fwhitespace"));
assertEquals("whitespace", formatter.format("whitespace \n \r"));
assertEquals("whitespace", formatter.format(" \f\t whitespace \r \n"));
@ParameterizedTest
@ValueSource(strings = {
// remove horizontal tabulation
"\twhitespace",
"whitespace\t",
"\twhitespace\t\t",

// remove line feeds
"\nwhitespace",
"whitespace\n",
"\nwhitespace\n\n",

// remove form feeds
"\fwhitespace",
"whitespace\f",
"\fwhitespace\f\f",

// remove carriage returns
"\rwhitespace",
"whitespace\r",
"\rwhitespace\r\r",

// remove spaces
" whitespace",
"whitespace ",
" whitespace ",

// remove combinations
" \r\t\fwhitespace",
"whitespace \n \r",
" \f\t whitespace \r \n",
})
void removeBlankCharacters(String expression) {
assertEquals("whitespace", formatter.format(expression));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;

import static org.junit.jupiter.api.Assertions.assertEquals;

Expand All @@ -22,16 +24,18 @@ void basic() {
assertEquals("aaa", formatter.format("aaa"));
}

@Test
void unicodeCombiningAccents() {
assertEquals("{\\\"{a}}", formatter.format("a\u0308"));
assertEquals("{\\\"{a}}b", formatter.format("a\u0308b"));
}

@Test
void unicode() {
assertEquals("{\\\"{a}}", formatter.format("ä"));
assertEquals("{{$\\Epsilon$}}", formatter.format("\u0395"));
@ParameterizedTest
@CsvSource(textBlock = """
# combining accents
{\\"{a}}, a\u0308
{\\"{a}}b, a\u0308b

# plain unicode letters
{\\"{a}}, ä
{{$\\Epsilon$}}, \u0395
""")
void unicode(String expected, String text) {
assertEquals(expected, formatter.format(text));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;

import static org.junit.jupiter.api.Assertions.assertEquals;

Expand All @@ -17,10 +19,14 @@ void setUp() {
formatter = new UnitsToLatexFormatter();
}

@Test
void test() {
assertEquals("1~{A}", formatter.format("1 A"));
assertEquals("1\\mbox{-}{mA}", formatter.format("1-mA"));
@ParameterizedTest
@CsvSource({"""
1~{A}, 1 A,
1\\mbox{-}{mA}, 1-mA
"""
})
void test(String expected, String text) {
assertEquals(expected, formatter.format(text));
}

@Test
Expand Down
Loading