-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDocumentParserTest.java
More file actions
50 lines (43 loc) · 1.2 KB
/
Copy pathDocumentParserTest.java
File metadata and controls
50 lines (43 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.Iterator;
public class DocumentParserTest
{
DocumentParser aParser;
String testString = "So it seems pretty likely that HTC will give us \nan Android-tablet at some point, although any hard and; fast details continue to. ";
char[] charArray = testString.toCharArray();
@Before
public void setUp() throws Exception
{
aParser = new DocumentParser(testString);
}
@After
public void tearDown() throws Exception
{
}
@Test
public void testGetAllWords()
{
Iterator itr = aParser.getAllWords();
Word temp;
while(itr.hasNext())
{
temp = (Word)itr.next();
if(temp != null)
{
assertEquals(temp.getWord().charAt(0), charArray[temp.getStartIndex()]);
System.out.println("Computed index ["+temp.getWord()+"] ["+temp.getStartIndex()+ "] || Real value at index ["+ charArray[temp.getStartIndex()]+"]");
}
}
}
@Test
public void testGetSnippet()
{
Snippet aSnip = aParser.getSnippet(0);
assertEquals(aSnip.getEndIndex(),80); //Should be the 80th index
aSnip = aParser.getSnippet(118);
assertEquals(aSnip.getEndIndex(),129); //Should be the 129th
}
}