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()));
    }
}

package org.jabref.logic.formatter.bibtexfields;

import java.util.stream.Stream;

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

class UnicodeToLatexFormatterTest {

    private UnicodeToLatexFormatter formatter;

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

    private static Stream<Arguments> testCases() {
        return Stream.of(
                         Arguments.of("", ""), // empty string input
                         Arguments.of("abc", "abc"), // non unicode input
                         Arguments.of("{{\\aa}}{\\\"{a}}{\\\"{o}}", "\u00E5\u00E4\u00F6"), // multiple unicodes input
                         Arguments.of("", "\u0081"), // high code point unicode, boundary case: cp = 129
                         Arguments.of("", "\u0080"), // high code point unicode, boundary case: cp = 128 < 129
                         Arguments.of("M{\\\"{o}}nch", new UnicodeToLatexFormatter().getExampleInput()));
    }

    @ParameterizedTest()
    @MethodSource("testCases")
    void testFormat(String expectedResult, String input) {
        assertEquals(expectedResult, formatter.format(input));
    }

}

fix checkstyle in unit test (#7749)