Subversion Repository Public Repository

litesoft

Diff Revisions 949 vs 950 for /trunk/Java/KeyHole/src/org/litesoft/aokeyhole/objects/support/ToLinesObjectsParseStreamTest.java

Diff revisions: vs.
  @@ -1,71 +1,71 @@
1 - // This Source Code is in the Public Domain per: http://unlicense.org
2 - package org.litesoft.aokeyhole.objects.support;
3 -
4 - import org.litesoft.*;
5 - import org.litesoft.commonfoundation.typeutils.*;
6 -
7 - import junit.framework.*;
8 - import junit.textui.*;
9 -
10 - public class ToLinesObjectsParseStreamTest extends TestCasePlus {
11 - private static Class<ToLinesObjectsParseStreamTest> THIS = ToLinesObjectsParseStreamTest.class;
12 -
13 - public ToLinesObjectsParseStreamTest( String name ) {
14 - super( name );
15 - }
16 -
17 - public static void main( String[] args )
18 - throws Exception {
19 - TestRunner.run( suite() );
20 - System.exit( 0 );
21 - }
22 -
23 - public static TestSuite suite() {
24 - return new TestSuite( THIS );
25 - }
26 -
27 - public void test_toLinesParser()
28 - throws Exception {
29 - ToLinesObjectsParseStream ops = new ToLinesObjectsParseStream( (String[]) null );
30 - assertFalse( "null", ops.readLine() );
31 -
32 - ops = new ToLinesObjectsParseStream( Strings.EMPTY_ARRAY );
33 - assertFalse( "empty", ops.readLine() );
34 -
35 - ops = new ToLinesObjectsParseStream( " " );
36 - assertFalse( "Blank", ops.readLine() );
37 -
38 - ops = new ToLinesObjectsParseStream( "# Test" );
39 - assertFalse( "Comment #", ops.readLine() );
40 -
41 - ops = new ToLinesObjectsParseStream( "// Test" );
42 - assertFalse( "Comment //", ops.readLine() );
43 -
44 - ops = new ToLinesObjectsParseStream( "// Comment", //
45 - "One:1", //
46 - "", //
47 - "# 2nd real line follows", //
48 - "..Two:2=B", //
49 - ".Three:3|!2|", //
50 - "", //
51 - "" );
52 -
53 - validateLine( ops, 0, "One", '|', true, "1" );
54 - validateLine( ops, 2, "Two", '=', false, "2", "B" );
55 - validateLine( ops, 1, "Three", '|', false, "3", "!2", "" );
56 -
57 - assertFalse( "eof", ops.readLine() );
58 - }
59 -
60 - private void validateLine( ToLinesObjectsParseStream pOPS, int pDepth, String pTag, char pSeperator, boolean pNextDeeper, String... pData ) {
61 - assertTrue( "a" + pTag, pOPS.readLine() );
62 -
63 - assertEquals( "Depth: " + pTag, pDepth, pOPS.getDepth() );
64 -
65 - assertEquals( "Tag", pTag, pOPS.getWhat() );
66 -
67 - assertArraysEquals( "b" + pTag, pOPS.parseData( pData.length, pSeperator ), pData );
68 -
69 - assertEquals( "c" + pTag, pNextDeeper, pOPS.isNextDeeper() );
70 - }
71 - }
1 + // This Source Code is in the Public Domain per: http://unlicense.org
2 + package org.litesoft.aokeyhole.objects.support;
3 +
4 + import org.litesoft.*;
5 + import org.litesoft.commonfoundation.typeutils.*;
6 +
7 + import junit.framework.*;
8 + import junit.textui.*;
9 +
10 + public class ToLinesObjectsParseStreamTest extends TestCasePlus {
11 + private static Class<ToLinesObjectsParseStreamTest> THIS = ToLinesObjectsParseStreamTest.class;
12 +
13 + public ToLinesObjectsParseStreamTest( String name ) {
14 + super( name );
15 + }
16 +
17 + public static void main( String[] args )
18 + throws Exception {
19 + TestRunner.run( suite() );
20 + System.exit( 0 );
21 + }
22 +
23 + public static TestSuite suite() {
24 + return new TestSuite( THIS );
25 + }
26 +
27 + public void test_toLinesParser()
28 + throws Exception {
29 + ToLinesObjectsParseStream ops = new ToLinesObjectsParseStream( (String[]) null );
30 + assertFalse( "null", ops.readLine() );
31 +
32 + ops = new ToLinesObjectsParseStream( Strings.EMPTY_ARRAY );
33 + assertFalse( "empty", ops.readLine() );
34 +
35 + ops = new ToLinesObjectsParseStream( " " );
36 + assertFalse( "Blank", ops.readLine() );
37 +
38 + ops = new ToLinesObjectsParseStream( "# Test" );
39 + assertFalse( "Comment #", ops.readLine() );
40 +
41 + ops = new ToLinesObjectsParseStream( "// Test" );
42 + assertFalse( "Comment //", ops.readLine() );
43 +
44 + ops = new ToLinesObjectsParseStream( "// Comment", //
45 + "One:1", //
46 + "", //
47 + "# 2nd real line follows", //
48 + "..Two:2=B", //
49 + ".Three:3|!2|", //
50 + "", //
51 + "" );
52 +
53 + validateLine( ops, 0, "One", '|', true, "1" );
54 + validateLine( ops, 2, "Two", '=', false, "2", "B" );
55 + validateLine( ops, 1, "Three", '|', false, "3", "!2", "" );
56 +
57 + assertFalse( "eof", ops.readLine() );
58 + }
59 +
60 + private void validateLine( ToLinesObjectsParseStream pOPS, int pDepth, String pTag, char pSeperator, boolean pNextDeeper, String... pData ) {
61 + assertTrue( "a" + pTag, pOPS.readLine() );
62 +
63 + assertEquals( "Depth: " + pTag, pDepth, pOPS.getDepth() );
64 +
65 + assertEquals( "Tag", pTag, pOPS.getWhat() );
66 +
67 + assertArraysEquals( "b" + pTag, pOPS.parseData( pData.length, pSeperator ), pData );
68 +
69 + assertEquals( "c" + pTag, pNextDeeper, pOPS.isNextDeeper() );
70 + }
71 + }