1 package com.hughes.android.dictionary.parser;
3 import junit.framework.TestCase;
5 public class WikiLineReaderTest extends TestCase {
7 public void testSimple() {
8 final String wikiText =
10 "Hello thad you're <!-- not --> '''pretty''' cool '''''over''''' there." + "\n" +
13 "# comment -->" + "\n" +
16 "# {{template_in_list}}" + "\n" +
17 "[[wikitext]]:[[wikitext]]" + "\n" + // don't want this to trigger a list
18 "here's [[some blah|some]] wikitext." + "\n" +
19 "here's a {{template|this has an = sign|blah=2|blah2=3|" + "\n" +
20 "blah3=3,[[asdf]|[asdf asdf]|[asdf asdf asdf]],blah4=4}} and some more text." + "\n" +
21 "== Header 2 ==" + "\n" +
22 "{{some-func|blah={{nested-func|n2}}|blah2=asdf}}" + "\n" +
23 "{{unterminated}" + "\n" +
24 "[[unterminated]" + "\n" +
25 "=== {{header-template}} ===" + "\n";
27 final String[] expected = new String[] {
29 "Hello thad you're '''pretty''' cool '''''over''''' there.",
33 "# {{template_in_list}}",
34 "[[wikitext]]:[[wikitext]]",
35 "here's [[some blah|some]] wikitext.",
36 "here's a {{template|this has an = sign|blah=2|blah2=3| blah3=3,[[asdf]|[asdf asdf]|[asdf asdf asdf]],blah4=4}} and some more text.",
38 "{{some-func|blah={{nested-func|n2}}|blah2=asdf}}",
41 "=== {{header-template}} ===",
44 final WikiLineReader wikiLineReader = new WikiLineReader(wikiText);
45 for (int i = 0; i < expected.length; ++i) {
46 assertEquals(expected[i], WikiLineReader.cleanUpLine(wikiLineReader.readLine()));
48 final String end = wikiLineReader.readLine();
50 System.out.println(WikiLineReader.cleanUpLine(end));