package net.sf.jabref.logic.layout.format;

import org.junit.Ignore;
import org.junit.Test;

import static org.junit.Assert.assertEquals;


public class LatexToUnicodeFormatterTest {

    public final LatexToUnicodeFormatter formatter = new LatexToUnicodeFormatter();

    @Test
    public void testPlainFormat() {
        assertEquals("aaa", formatter.format("aaa"));
    }

    @Test
    public void testFormatUmlaut() {
        assertEquals("ä", formatter.format("{\\\"{a}}"));
        assertEquals("Ä", formatter.format("{\\\"{A}}"));
    }

    @Test
    public void testFormatStripLatexCommands() {
        assertEquals("-", formatter.format("\\mbox{-}"));
    }

    @Test
    public void testFormatTextit() {
        // See #1464
        assertEquals("\uD835\uDC61\uD835\uDC52\uD835\uDC65\uD835\uDC61", formatter.format("\\textit{text}"));
    }


    @Test
    public void testEscapedDollarSign() {
        assertEquals("$", formatter.format("\\$"));
    }

    @Test
    public void testEquationsSingleSymbol() {
        assertEquals("σ", formatter.format("$\\sigma$"));
    }

    @Test
    public void testEquationsMoreComplicatedFormatting() {
        assertEquals("A 32 mA ΣΔ-modulator", formatter.format("A 32~{mA} {$\\Sigma\\Delta$}-modulator"));
    }

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

    @Test
    public void testChi() {
        // See #1464
        assertEquals("χ", formatter.format("$\\chi$"));
    }

    @Test
    public void testSWithCaron() {
        // Bug #1264
        assertEquals("Š", formatter.format("{\\v{S}}"));
    }

    @Test
    public void testCombiningAccentsCase1() {
        assertEquals("ḩ", formatter.format("{\\c{h}}"));
    }

    @Ignore("This is not a standard LaTeX command. It is debatable why we should convert this.")
    @Test
    public void testCombiningAccentsCase2() {
        assertEquals("a͍", formatter.format("\\spreadlips{a}"));
    }

    @Test
    public void unknownCommandIsIgnored() {
        assertEquals("", formatter.format("\\aaaa"));
    }

    @Test
    public void unknownCommandKeepsArgument() {
        assertEquals("bbbb", formatter.format("\\aaaa{bbbb}"));
    }

    @Test
    public void unknownCommandWithEmptyArgumentIsIgnored() {
        assertEquals("", formatter.format("\\aaaa{}"));
    }

    @Test
    public void testTildeN() {
        assertEquals("Montaña", formatter.format("Monta\\~{n}a"));
    }

    @Test
    public void testAcuteNLongVersion() {
        assertEquals("Maliński", formatter.format("Mali\\'{n}ski"));
        assertEquals("MaliŃski", formatter.format("Mali\\'{N}ski"));
    }

    @Test
    public void testAcuteNShortVersion() {
        assertEquals("Maliński", formatter.format("Mali\\'nski"));
        assertEquals("MaliŃski", formatter.format("Mali\\'Nski"));
    }

    @Test
    public void testApostrophN() {
        assertEquals("Mali'nski", formatter.format("Mali'nski"));
        assertEquals("Mali'Nski", formatter.format("Mali'Nski"));
    }

    @Test
    public void testApostrophO() {
        assertEquals("L'oscillation", formatter.format("L'oscillation"));
    }

    @Test
    public void testApostrophC() {
        assertEquals("O'Connor", formatter.format("O'Connor"));
    }
}

@@ -1636,32 +1636,912 @@
 %7BS%7D%7D%22));%0A    %7D%0A%0A
+    @Test%0A    public void testIWithDiaresis() %7B%0A        assertEquals(%22%C3%AF%22, formatter.format(%22%5C%5C%5C%22%7Bi%7D%22));%0A    %7D%0A%0A    @Test%0A    public void testIWithDiaresisAndEscapedI() %7B%0A        // this might look strange in the test, but is actually a correct translation and renders identically to the above example in the UI%0A        assertEquals(%22%C4%B1%CC%88%22, formatter.format(%22%5C%5C%5C%22%7B%5C%5Ci%7D%22));%0A    %7D%0A%0A%0A    @Test%0A    public void testIWithDiaresisAndUnnecessaryBraces() %7B%0A        assertEquals(%22%C3%AF%22, formatter.format(%22%7B%5C%5C%5C%22%7Bi%7D%7D%22));%0A    %7D%0A%0A    @Test%0A    public void testUpperCaseIWithDiaresis() %7B%0A        assertEquals(%22%C3%8F%22, formatter.format(%22%5C%5C%5C%22%7BI%7D%22));%0A    %7D%0A%0A    @Test%0A    public void testPolishName() %7B%0A        assertEquals(%22%C5%81%C4%99ski%22, formatter.format(%22%5C%5CL%5C%5Ck%7Be%7Dski%22));%0A    %7D%0A%0A%0A    @Test%0A    public void testDoubleCombiningAccents() %7B%0A        assertEquals(%22%CF%8E%22, formatter.format(%22$%5C%5Cacute%7B%5C%5Comega%7D$%22));%0A    %7D%0A%0A
     @Test%0A    pu

Add more tests for LaTeX to unicode conversion