[Htmlparser-cvs] htmlparser/src/org/htmlparser/tests/lexerTests SourceTests.java,1.13,1.14
Brought to you by:
derrickoswald
From: <der...@us...> - 2003-12-31 04:03:40
|
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/lexerTests In directory sc8-pr-cvs1:/tmp/cvs-serv1538 Modified Files: SourceTests.java Log Message: Fix Source 'SameChars' test. Index: SourceTests.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/lexerTests/SourceTests.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** SourceTests.java 8 Dec 2003 01:31:54 -0000 1.13 --- SourceTests.java 31 Dec 2003 04:03:37 -0000 1.14 *************** *** 296,336 **** { String link; - ArrayList chars1; - ArrayList chars2; URL url; ! URLConnection connection; InputStreamReader in; ! int c; Source source; int index; // pick a big file ! link = "http://sourceforge.net/projects/htmlparser/HTMLParser_Coverage.html"; ! chars1 = new ArrayList (); ! chars2 = new ArrayList (); try { url = new URL (link); ! connection = url.openConnection (); ! connection.connect (); ! in = new InputStreamReader (new BufferedInputStream (connection.getInputStream ()), DEFAULT_CHARSET); ! while (-1 != (c = in.read ())) ! chars1.add (new Character ((char)c)); ! in.close (); ! ! connection = url.openConnection (); ! connection.connect (); ! source = new Source (new Stream (connection.getInputStream ())); ! while (-1 != (c = source.read ())) ! chars2.add (new Character ((char)c)); ! source.close (); ! index = 0; ! while (index < chars1.size ()) { ! assertEquals ("characters differ at position " + index, chars1.get (index), chars2.get (index)); index++; } ! assertTrue ("extra characters", index == chars2.size ()); } catch (MalformedURLException murle) --- 296,331 ---- { String link; URL url; ! URLConnection connection1; ! URLConnection connection2; InputStreamReader in; ! int c1; ! int c2; Source source; int index; // pick a big file ! link = "http://htmlparser.sourceforge.net/HTMLParser_Coverage.html"; try { url = new URL (link); ! connection1 = url.openConnection (); ! connection1.connect (); ! in = new InputStreamReader (new BufferedInputStream (connection1.getInputStream ()), "UTF-8"); ! connection2 = url.openConnection (); ! connection2.connect (); ! source = new Source (new Stream (connection2.getInputStream ()), "UTF-8"); index = 0; ! while (-1 != (c1 = in.read ())) { ! c2 = source.read (); ! if (c1 != c2) ! fail ("characters differ at position " + index + ", expected " + c1 + ", actual " + c2); index++; } ! c2 = source.read (); ! assertTrue ("extra characters", -1 == c2); ! source.close (); ! in.close (); } catch (MalformedURLException murle) |