Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/eireneh/bible/book/raw/ZTestBibleBookRaw.java


1   
2   package com.eireneh.bible.book.raw;
3   
4   import java.io.*;
5   import java.util.*;
6   
7   import com.eireneh.util.*;
8   import com.eireneh.bible.passage.*;
9   import com.eireneh.bible.book.*;
10  
11  /**
12  * Attepmted 100% code coverage testing.
13  *
14  * <table border='1' cellPadding='3' cellSpacing='0' width="100%">
15  * <tr><td bgColor='white'class='TableRowColor'><font size='-7'>
16  * Distribution Licence:<br />
17  * Project B is free software; you can redistribute it
18  * and/or modify it under the terms of the GNU General Public License,
19  * version 2 as published by the Free Software Foundation.<br />
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23  * General Public License for more details.<br />
24  * The License is available on the internet
25  * <a href='http://www.gnu.org/copyleft/gpl.html'>here</a>, by writing to
26  * <i>Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
27  * MA 02111-1307, USA</i>, Or locally at the Licence link below.<br />
28  * The copyright to this program is held by it's authors.
29  * </font></td></tr></table>
30  * @see <a href='http://www.eireneh.com/servlets/Web'>Project B Home</a>
31  * @see docs.Licence
32  * @author Joe Walker
33  */
34  public class ZTestBibleBookRaw extends TestBase
35  {
36      /**
37      * A basic are we OK type test, for the Passage package.
38      */
39      public void test(PrintWriter out, boolean fatal)
40      {
41          logPackageStart(out, fatal, ZTestBibleBookRaw.class);
42  
43          testRawUtil();
44  
45          logPackageStop();
46      }
47  
48      /**
49      * Test the RawUtil class.
50      */
51      public static void testRawUtil()
52      {
53          try
54          {
55              log("RawBible.none()");
56  
57              /*
58              RawBible raw = new RawBible();
59              WordResource words = raw.getWordResource();
60              WordInstResource wordinsts = raw.getWordInstResource();
61              String[] test;
62  
63              log("RawUtil.tokenize(String)");
64              test = RawUtil.tokenize("one two three");
65              test(test.length, 3);
66              test(test[0], "one ");
67              test(test[1], "two ");
68              test(test[2], "three");
69              test = RawUtil.tokenize("one");
70              test(test.length, 1);
71              test(test[0], "one");
72              test = RawUtil.tokenize("One, !Two-er THREE-er?");
73              test(test.length, 3);
74              test(test[0], "One, ");
75              test(test[1], "!Two-er ");
76              test(test[2], "THREE-er?");
77              test = RawUtil.tokenize("One, !Two-er THREE--four?");
78              test(test.length, 4);
79              test(test[0], "One, ");
80              test(test[1], "!Two-er ");
81              test(test[2], "THREE--");
82              test(test[3], "four?");
83  
84              log("RawUtil.stripPunctuation(String)");
85              test(RawUtil.stripPunctuation("abcde"), "abcde");
86              test(RawUtil.stripPunctuation("a---e"), "a---e");
87              test(RawUtil.stripPunctuation("a'''e"), "a'''e");
88              test(RawUtil.stripPunctuation("a'e-e"), "a'e-e");
89              test(RawUtil.stripPunctuation("12345"), "12345");
90              test(RawUtil.stripPunctuation("'abcde"), "abcde");
91              test(RawUtil.stripPunctuation("'a---e"), "a---e");
92              test(RawUtil.stripPunctuation("'a'''e"), "a'''e");
93              test(RawUtil.stripPunctuation("'a'e-e"), "a'e-e");
94              test(RawUtil.stripPunctuation("'12345"), "12345");
95              test(RawUtil.stripPunctuation("'abcde'"), "abcde");
96              test(RawUtil.stripPunctuation("'a---e'"), "a---e");
97              test(RawUtil.stripPunctuation("'a'''e'"), "a'''e");
98              test(RawUtil.stripPunctuation("'a'e-e'"), "a'e-e");
99              test(RawUtil.stripPunctuation("'12345'"), "12345");
100             test(RawUtil.stripPunctuation("'-abcde--"), "abcde");
101             test(RawUtil.stripPunctuation("'-a---e--"), "a---e");
102             test(RawUtil.stripPunctuation("'-a'''e--"), "a'''e");
103             test(RawUtil.stripPunctuation("'-a'e-e--"), "a'e-e");
104             test(RawUtil.stripPunctuation("'-12345--"), "12345");
105             test(RawUtil.stripPunctuation("$'-abcde-'*"), "abcde");
106             test(RawUtil.stripPunctuation("$'-a---e-'*"), "a---e");
107             test(RawUtil.stripPunctuation("$'-a'''e-'*"), "a'''e");
108             test(RawUtil.stripPunctuation("$'-a'e-e-'*"), "a'e-e");
109             test(RawUtil.stripPunctuation("$'-12345-'*"), "12345");
110             test(RawUtil.stripPunctuation("`'-abcde-'["), "abcde");
111             test(RawUtil.stripPunctuation("`'-a---e-'["), "a---e");
112             test(RawUtil.stripPunctuation("`'-a'''e-'["), "a'''e");
113             test(RawUtil.stripPunctuation("`'-a'e-e-'["), "a'e-e");
114             test(RawUtil.stripPunctuation("`'-12345-'["), "12345");
115             test(RawUtil.stripPunctuation("#'-abcde-'}"), "abcde");
116             test(RawUtil.stripPunctuation("#'-a---e-'}"), "a---e");
117             test(RawUtil.stripPunctuation("#'-a'''e-'}"), "a'''e");
118             test(RawUtil.stripPunctuation("#'-a'e-e-'}"), "a'e-e");
119             test(RawUtil.stripPunctuation("#'-12345-'}"), "12345");
120             test(RawUtil.stripPunctuation("£'-abcde-'/"), "abcde");
121             test(RawUtil.stripPunctuation("£'-a---e-'/"), "a---e");
122             test(RawUtil.stripPunctuation("£'-a'''e-'/"), "a'''e");
123             test(RawUtil.stripPunctuation("£'-a'e-e-'/"), "a'e-e");
124             test(RawUtil.stripPunctuation("£'-12345-'/"), "12345");
125 
126             log("RawUtil.stripPunctuation(String[])");
127             test = RawUtil.stripPunctuation(StringUtil.tokenize("aaaa", " "));
128             test(test.length, 1);
129             test(test[0], "aaaa");
130             test = RawUtil.stripPunctuation(StringUtil.tokenize("aaaa bbbb", " "));
131             test(test.length, 2);
132             test(test[0], "aaaa");
133             test(test[1], "bbbb");
134             test = RawUtil.stripPunctuation(StringUtil.tokenize("One Two Three", " "));
135             test(test.length, 3);
136             test(test[0], "One");
137             test(test[1], "Two");
138             test(test[2], "Three");
139             test = RawUtil.stripPunctuation(StringUtil.tokenize(" One  Two  Three ", " "));
140             test(test.length, 3);
141             test(test[0], "One");
142             test(test[1], "Two");
143             test(test[2], "Three");
144             test = RawUtil.stripPunctuation(StringUtil.tokenize(" 'One's' ,Two? !Three-Four\" ", " "));
145             test(test.length, 3);
146             test(test[0], "One's");
147             test(test[1], "Two");
148             test(test[2], "Three-Four");
149             test = RawUtil.stripPunctuation(StringUtil.tokenize(" 'One's' ,Two? !Three-- Four\" ", " "));
150             test(test.length, 4);
151             test(test[0], "One's");
152             test(test[1], "Two");
153             test(test[2], "Three");
154             test(test[3], "Four");
155 
156             log("RawUtil.stripWords(String)");
157             test(RawUtil.stripWords("one", "two"), "");
158             test(RawUtil.stripWords("one,", "two"), ",");
159             test(RawUtil.stripWords("one'", "two"), "'");
160             test(RawUtil.stripWords("one-", "two"), "-");
161             test(RawUtil.stripWords("one#", "two"), "#");
162             test(RawUtil.stripWords("one", ",two"), ",");
163             test(RawUtil.stripWords("one", "'two"), "'");
164             test(RawUtil.stripWords("one", "-two"), "-");
165             test(RawUtil.stripWords("one", "#two"), "#");
166             test(RawUtil.stripWords("one-", "-two"), "--");
167             test(RawUtil.stripWords("-one-", "-two-"), "--");
168             test(RawUtil.stripWords("one-world", "two"), "");
169             test(RawUtil.stripWords("one-world'", "two"), "'");
170             test(RawUtil.stripWords("one ", "two"), " ");
171             test(RawUtil.stripWords("one, ", "two"), ", ");
172             test(RawUtil.stripWords("one' ", "two"), "' ");
173             test(RawUtil.stripWords("one- ", "two"), "- ");
174             test(RawUtil.stripWords("one# ", "two"), "# ");
175             test(RawUtil.stripWords("one", " ,two"), " ,");
176             test(RawUtil.stripWords("one", " 'two"), " '");
177             test(RawUtil.stripWords("one", " -two"), " -");
178             test(RawUtil.stripWords("one" , "#two"), "#");
179             test(RawUtil.stripWords("one- ", "-two"), "- -");
180             test(RawUtil.stripWords("-one- ", "-two-"), "- -");
181             test(RawUtil.stripWords("one-world ", "two"), " ");
182             test(RawUtil.stripWords("one-world'", " two"), "' ");
183 
184             log("RawUtil.stripWords(String[])");
185             test = RawUtil.stripWords(StringUtil.tokenize(" 'One's' ,Two? !Three-Four\" ", " "));
186             test(test.length, 4);
187             test(test[0], "'");
188             test(test[1], "',");
189             test(test[2], "?!");
190             test(test[3], "\"");
191             test = RawUtil.stripWords(StringUtil.tokenize(" 'One's' ,Two? !Three-- Four\" ", " "));
192             test(test.length, 5);
193             test(test[0], "'");
194             test(test[1], "',");
195             test(test[2], "?!");
196             test(test[3], "--");
197             test(test[4], "\"");
198             test = RawUtil.stripWords(RawUtil.tokenize("'One's' ,Two? !Three--Four\""));
199             test(test.length, 5);
200             test(test[0], "'");
201             test(test[1], "' ,");
202             test(test[2], "? !");
203             test(test[3], "--");
204             test(test[4], "\"");
205 
206             log("WordResource.getIndex(String)");
207             int in = words.getIndex("in");
208             int th = words.getIndex("the");
209             int be = words.getIndex("beginning");
210             int go = words.getIndex("god");
211             int cr = words.getIndex("created");
212             test(in, words.getIndex("in"));
213             test(th, words.getIndex("the"));
214             test(be, words.getIndex("beginning"));
215             test(go, words.getIndex("god"));
216             test(cr, words.getIndex("created"));
217             test(in != th);
218             test(in != be);
219             test(in != go);
220             test(in != cr);
221             test(th != be);
222             test(th != go);
223             test(th != cr);
224             test(be != go);
225             test(be != cr);
226             test(go != cr);
227             int g2 = words.getIndex("gods");
228             int g3 = words.getIndex("god");
229             int g4 = words.getIndex("god's");
230             int g5 = words.getIndex("godly");
231             int g6 = words.getIndex("good");
232             test(g2, words.getIndex("gods"));
233             test(g3, words.getIndex("god"));
234             test(g4, words.getIndex("god's"));
235             test(g5, words.getIndex("godly"));
236             test(g6, words.getIndex("good"));
237             test(go != g2);
238             test(go, g3);
239             test(go != g4);
240             test(go != g5);
241             test(go != g6);
242             test(g2 != g3);
243             test(g2 != g4);
244             test(g2 != g5);
245             test(g2 != g6);
246             test(g3 != g4);
247             test(g3 != g5);
248             test(g3 != g6);
249             test(g4 != g5);
250             test(g4 != g6);
251             test(g5 != g6);
252 
253             log("WordResource.getIndex(String[])");
254             int[] idx = words.getIndex(new String[] { "in", "the", "beginning", "did", "god" });
255             test(idx[0], in);
256             test(idx[1], th);
257             test(idx[2], be);
258             test(idx[3], words.getIndex("did"));
259             test(idx[4], go);
260 
261             log("WordResource.getWords()");
262             Enumeration en = words.getEnumeration();
263             while (en.hasMoreElements())
264             {
265                 String word = (String) en.nextElement();
266                 int index = words.getIndex(word);
267                 String word2 = words.getItem(index);
268                 test(word, word2);
269             }
270 
271             log("WordResource.getWord(int)");
272             test("in", words.getItem(in));
273             test("the", words.getItem(th));
274             test("beginning", words.getItem(be));
275             test("god", words.getItem(go));
276             test("created", words.getItem(cr));
277             test("good", words.getItem(g6));
278 
279             log("WordInstResource.setWords(int[], Verse)");
280             int[] widx = new int[] { 0, 1, 2, 3, 4 };
281             wordinsts.setIndexes(widx, new Verse(1));
282 
283             log("WordInstResource.getWords(int[])");
284             int[] widx2 = wordinsts.getIndexes(new Verse(1));
285             test(widx, widx2);
286             */
287 
288             // I'm making these tests do for the Punc[Inst]Resource
289             // classes as they are to similar.
290         }
291         catch (Exception ex)
292         {
293             fail(ex);
294         }
295     }
296 }
297