package fitnesse.wikitext.test;

import org.junit.Test;
import static org.junit.Assert.assertTrue;

public class EqualPairTest {
    @Test public void scansTripleQuotes() {
        ParserTestHelper.assertScansTokenType("'''bold'''", "Bold", true);
        ParserTestHelper.assertScansTokenType("''''bold''''", "Bold", true);
        ParserTestHelper.assertScansTokenType("'' 'not bold' ''", "Bold", false);
        ParserTestHelper.assertScansTokenType("''''some text' '''", "Bold", true);
    }

    @Test public void translatesBold() {
        ParserTestHelper.assertTranslatesTo("'''bold text'''", "<b>bold text</b>");
    }

    @Test public void scansDoubleQuotes() {
        ParserTestHelper.assertScansTokenType("''italic''", "Italic", true);
        ParserTestHelper.assertScansTokenType("'' 'italic' ''", "Italic", true);
    }

    @Test public void translatesItalic() {
        ParserTestHelper.assertTranslatesTo("''italic text''", "<i>italic text</i>");
    }

    @Test public void translatesBoldItalic() {
        ParserTestHelper.assertTranslatesTo("'''''stuff&nonsense'''''",
          "<b><i>stuff&amp;nonsense</i></b>");
    }

    @Test public void ignoresAdjacentItalics() {
        ParserTestHelper.assertTranslatesTo("''", "''");
        ParserTestHelper.assertTranslatesTo("''''", "''''");
    }

    @Test public void translatesItalicQuote() {
        ParserTestHelper.assertTranslatesTo("'''''", "<i>'</i>");
    }

    @Test public void scansDoubleDashes() {
        ParserTestHelper.assertScansTokenType("abc--123--def", "Strike", true);
        ParserTestHelper.assertScansTokenType("--- -", "Strike", true);
    }

    @Test public void translatesStrike() {
        ParserTestHelper.assertTranslatesTo("--some text--", "<strike>some text</strike>");
        ParserTestHelper.assertTranslatesTo("--embedded-dash--", "<strike>embedded-dash</strike>");
    }

    @Test public void testEvilExponentialMatch() throws Exception {
        long startTime = System.currentTimeMillis();

        ParserTestHelper.assertTranslatesTo("--1234567890123456789012", "--1234567890123456789012");

        long endTime = System.currentTimeMillis();
        assertTrue("took too long", endTime - startTime < 20);
    }
}

@@ -1882,352 +1882,7 @@
    %7D
-%0A%0A    @Test public void testEvilExponentialMatch() throws Exception %7B%0A        long startTime = System.currentTimeMillis();%0A%0A        ParserTestHelper.assertTranslatesTo(%22--1234567890123456789012%22, %22--1234567890123456789012%22);%0A%0A        long endTime = System.currentTimeMillis();%0A        assertTrue(%22took too long%22, endTime - startTime %3C 20);%0A    %7D
 %0A%7D%0A

remove old test