+// Copyright 2011 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package com.hughes.android.dictionary.parser;
import java.util.ArrayList;
wikiText = "* This is ''bold''' asdf.";
assertEquals(wikiText, new WikiTokenizer(wikiText).nextToken().token());
+
+ wikiText = "* {{a|US}} {{IPA|[ˈfɔɹ.wɝd]]}}\nasdf\n";
+ assertEquals("* {{a|US}} {{IPA|[ˈfɔɹ.wɝd]]}}", new WikiTokenizer(wikiText).nextToken().token());
+ assertTrue(new WikiTokenizer(wikiText).nextToken().isListItem());
+ assertEquals("\n", new WikiTokenizer(wikiText).nextToken().nextToken().token());
+
}
public void testFunction() {
assertEquals("202", new WikiTokenizer(wikiText).nextToken().functionNamedArgs().get("arg2"));
assertEquals("{{n1|n2=7|n3}}", new WikiTokenizer(wikiText).nextToken().functionNamedArgs().get("arg3"));
+ wikiText = "{{gloss|asdf}\nAsdf\n\n";
+ assertEquals("{{gloss|asdf}", new WikiTokenizer(wikiText).nextToken().token());
+
+ wikiText = "#*{{quote-book|year=1960|author={{w|P. G. Wodehouse}}\n" +
+ "|title={{w|Jeeves in the Offing}}\n" +
+ "|section=chapter XI\n" +
+ "|passage=“I'm sorely beset, Jeeves. Do you recall telling me once about someone who told somebody he could tell him something which would make him think a bit? Knitted socks and porcu\n" +
+ "pines entered into it, I remember.” “I think you may be referring to the ghost of the father of Hamlet, Prince of Denmark, sir. Addressing his son, he said ‘I could a tale unfold whos\n" +
+ "e lightest word would harrow up thy soul, freeze thy young blood, make thy two eyes, like stars, start from their spheres, thy knotted and combined locks to part and each particular h\n" +
+ "air to stand on end like quills upon the fretful '''porpentine'''.’ ” “That's right. Locks, of course, not socks. Odd that he should have said '''porpentine''' when he meant porc\n" +
+ "upine. Slip of the tongue, no doubt, as so often happens with ghosts.”}}";
+ assertEquals(wikiText, new WikiTokenizer(wikiText).nextToken().token());
+
}
assertTrue(new WikiTokenizer(wikiText).nextToken().isHeading());
assertEquals(1, new WikiTokenizer(wikiText).nextToken().headingDepth());
assertEquals("a", new WikiTokenizer(wikiText).nextToken().headingWikiText());
- assertEquals(1, new WikiTokenizer(wikiText).nextToken().errors.size());
+ assertEquals(2, new WikiTokenizer(wikiText).nextToken().errors.size());
wikiText = "=a==";
assertEquals("=a==", new WikiTokenizer(wikiText).nextToken().token());
assertEquals(2, new WikiTokenizer(wikiText).nextToken().headingDepth());
assertEquals("aa[[|=]] {{|={{=}} }}", new WikiTokenizer(wikiText).nextToken().headingWikiText());
assertEquals(0, new WikiTokenizer(wikiText).nextToken().errors.size());
+
}