|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbb.io.ParseReader.UnitTest
public static class ParseReader.UnitTest
See the Overview page of the project's javadocs for a general description of this unit test class.
Field Summary | |
---|---|
private static String[] |
lineTerminators
|
private static int |
numberLines
|
private static int |
numberTests
|
private static Random |
random
|
private static String |
testString
|
Constructor Summary | |
---|---|
ParseReader.UnitTest()
|
Method Summary | |
---|---|
private static void |
doArrayRead(ParseReader parseReader,
StringBuilder readStorage)
Perform the operation of reading a char[] of some random size. |
private static void |
doArrayUnRead(ParseReader parseReader,
StringBuilder readStorage)
Perform the operation of unreading a char[] of some random size. |
private static void |
doConsistencyCheck(ParseReader parseReader,
StringBuilder readStorage)
First checks that parseReader has data left to read. |
private static void |
doManySingleReads(ParseReader parseReader,
StringBuilder readStorage)
Perform the operation of reading a single char some random number of times. |
private static void |
doManySingleUnreads(ParseReader parseReader,
StringBuilder readStorage)
Perform the operation of unreading a single char some random number of times. |
private static void |
doReadLine(ParseReader parseReader,
StringBuilder readStorage)
Perform the operation of reading 1 line of data. |
private static void |
doReadThruToken(ParseReader parseReader,
StringBuilder readStorage)
Tests readThruToken. |
private static void |
doSkip(ParseReader parseReader,
StringBuilder readStorage)
First calls doReadLine so that stream is positioned at the known beginning of a line. |
private static void |
doSkipFully(ParseReader parseReader,
StringBuilder readStorage)
First calls doReadLine so that stream is positioned at the known beginning of a line. |
private static void |
doSkipTillTokenNext(ParseReader parseReader,
StringBuilder readStorage)
Tests skipTillTokenNext. |
private static void |
doSkipWhitespace(ParseReader parseReader,
StringBuilder readStorage)
First calls doReadLine so that stream is positioned at the known beginning of a line. |
private static String |
getNthLineTerminator(int n)
Returns the value from lineTerminators at index = n % lineTerminators.length. |
private static String |
makeTestString(int length)
Make a test String which has the property that every line consists of the line number's characters followed by a line termination sequence determined by the getNthLineTerminator method. |
private static void |
printLastSeveralCharsRead(StringBuilder readStorage)
Confirm that the ParseReader's idea of lineNumber is consistent with the value recorded on the last line read. |
void |
test_all()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final Random random
private static final String[] lineTerminators
private static final int numberLines
private static final String testString
private static final int numberTests
Constructor Detail |
---|
public ParseReader.UnitTest()
Method Detail |
---|
public void test_all() throws Exception
Exception
private static String makeTestString(int length)
private static String getNthLineTerminator(int n)
private static void doManySingleReads(ParseReader parseReader, StringBuilder readStorage) throws IOException
IOException
private static void doArrayRead(ParseReader parseReader, StringBuilder readStorage) throws IOException
IOException
private static void doReadLine(ParseReader parseReader, StringBuilder readStorage) throws IOException
IOException
private static void doConsistencyCheck(ParseReader parseReader, StringBuilder readStorage) throws IOException, ParseException, RuntimeException
Then confirms that parseReader's idea of lineNumber is consistent with the value on the current line. This implies that this method may only be called when have just read thru a line termination sequence, so that the start of a line is what is immediately next on the stream. For example, this method may always safely be called after calling readLine.
Next, confirms that the line terminator sequence of the current line is correct. If the line terminator sequence is what is expected, then it is read thru so that the stream now points to the start of the next line (i.e. the one following the line that used to be next on the stream when method was called). If a different line terminator sequence is encountered, however, then it is NOT read thru but is left next on the stream.
This method tests the following methods: ready, hasData, getLineNumber, isTokenNext, confirmTokenNext.
Warning: this method assumes that the ParseReader was constructed with the result of makeTestString.
RuntimeException
- if any discrepancy is encountered
IOException
ParseException
private static void printLastSeveralCharsRead(StringBuilder readStorage)
Also confirm that the line terminator sequence is correct.
Warning: this method assumes that the ParseReader was constructed with the result of makeTestString.
private static void doManySingleUnreads(ParseReader parseReader, StringBuilder readStorage) throws IOException
IOException
private static void doArrayUnRead(ParseReader parseReader, StringBuilder readStorage) throws IOException
IOException
private static void doSkip(ParseReader parseReader, StringBuilder readStorage) throws IOException
IOException
private static void doSkipFully(ParseReader parseReader, StringBuilder readStorage) throws IOException
IOException
private static void doSkipWhitespace(ParseReader parseReader, StringBuilder readStorage) throws IOException, ParseException
IOException
ParseException
private static void doSkipTillTokenNext(ParseReader parseReader, StringBuilder readStorage) throws IOException, ParseException, RuntimeException
As a token, selects one of the remaining line numbers still ahead on the stream. Because of the need to store the skipped items in readStorage (which is done based on knowing what the tokens should look like), this method may only be called when have just read thru a line termination sequence, so that the start of a line is what is immediately next on the stream. For example, this method may always safely be called after calling readLine.
IOException
ParseException
RuntimeException
private static void doReadThruToken(ParseReader parseReader, StringBuilder readStorage) throws IOException, ParseException, RuntimeException
As a token, selects one of the remaining line numbers still ahead on the stream.
IOException
ParseException
RuntimeException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |