package org.jabref.logic.formatter.bibtexfields;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

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

class UnicodeToLatexFormatterTest {

    private UnicodeToLatexFormatter formatter;

    @BeforeEach
    void setUp() {
        formatter = new UnicodeToLatexFormatter();
    }

    @Test
    void formatWithoutUnicodeCharactersReturnsSameString() {
        assertEquals("abc", formatter.format("abc"));
    }

    @Test
    void formatMultipleUnicodeCharacters() {
        assertEquals("{{\\aa}}{\\\"{a}}{\\\"{o}}", formatter.format("\u00E5\u00E4\u00F6"));
    }

    @Test
    void formatHighCodepointUnicodeCharacter() {
        assertEquals("$\\epsilon$", formatter.format("\uD835\uDF16"));
    }

    @Test
    void formatExample() {
        assertEquals("M{\\\"{o}}nch", formatter.format(formatter.getExampleInput()));
    }
}

@@ -43,16 +43,49 @@
 ields;%0A%0A
+import java.util.stream.Stream;%0A%0A
 import o
@@ -146,16 +146,139 @@
 ter.
-api.Test
+params.ParameterizedTest;%0Aimport org.junit.jupiter.params.provider.Arguments;%0Aimport org.junit.jupiter.params.provider.MethodSource
 ;%0A%0Ai
@@ -524,211 +524,261 @@
     
-@Test%0A    void formatWithoutUnicodeCharactersReturnsSameString() %7B%0A        assertEquals(%22abc%22, formatter.format(%22abc%22));
+private static Stream%3CArguments%3E testCases() %7B%0A        return Stream.of(%0A                         Arguments.of(%22%22, %22%22), // empty string input
 %0A    
-%7D%0A%0A
     
-@Test%0A    void formatMultipleUnicodeCharacters() %7B%0A        assertEquals
+                 Arguments.of(%22abc%22, %22abc%22), // non unicode input%0A                         Arguments.of
 (%22%7B%7B
@@ -804,33 +804,16 @@
 %22%7Bo%7D%7D%22, 
-formatter.format(
 %22%5Cu00E5%5C
@@ -829,188 +829,479 @@
 F6%22)
-);%0A
+, // multiple unicodes input%0A   
     
-%7D%0A%0A
     
-@Test%0A    void formatHighC
+              Arguments.of(%22%C2%81%22, %22%5Cu0081%22), // high code point unicode, boundary case: cp = 129%0A                         Arguments.of(%22%C2%80%22, %22%5Cu0080%22), // high c
 ode
+ 
 point
-U
+ u
 nicode
-Character() %7B%0A        assertEquals(%22$%5C%5Cepsilon$%22, formatter.format(%22%5CuD835%5CuDF16%22));%0A    %7D%0A%0A    @Test%0A    void formatExample(
+, boundary case: cp = 128 %3C 129%0A                         Arguments.of(%22M%7B%5C%5C%5C%22%7Bo%7D%7Dnch%22, new UnicodeToLatexFormatter().getExampleInput()));%0A    %7D%0A%0A    @ParameterizedTest()%0A    @MethodSource(%22testCases%22)%0A    void testFormat(String expectedResult, String input
 ) %7B%0A
@@ -1321,31 +1321,30 @@
 tEquals(
-%22M%7B%5C%5C%5C%22%7Bo%7D%7Dnch%22
+expectedResult
 , format
@@ -1358,35 +1358,13 @@
 mat(
-formatter.getExampleI
+i
 nput
-()
 ));%0A
@@ -1369,10 +1369,11 @@
 ;%0A    %7D%0A
+%0A
 %7D%0A

fix checkstyle in unit test (#7749)