CVS Update: xmlpull-api-v1/src/java/tests/org/xmlpull/v1/tests

Aleksander Andrzej Slominski <[email protected]> Sun, 15 Jun 2003 11:29:40 -0500 (EST)
Newsgroups gmane.text.xml.xmlpull.devel
Message-ID <[email protected]>
aslom       03/06/15 11:29:40

  Modified:    src/java/tests/org/xmlpull/v1/tests TestMisc.java
  Log:
  updated tests for COMMENT and PROCESSING_INSTRUCTIONS to check for EOL normalization
  
  Revision  Changes    Path
  1.18      +108 -0    xmlpull-api-v1/src/java/tests/org/xmlpull/v1/tests/TestMisc.java
  
  Index: TestMisc.java
  ===================================================================
  RCS file: /l/extreme/cvspub/xmlpull-api-v1/src/java/tests/org/xmlpull/v1/tests/TestMisc.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -b -t -w -r1.17 -r1.18
  --- TestMisc.java	3 May 2003 06:37:45 -0000	1.17
  +++ TestMisc.java	15 Jun 2003 16:29:40 -0000	1.18
  @@ -283,6 +283,8 @@
           testContentMerging(pp, "<foo><!-- this is a comment --></foo>", null);
           testContentMerging(pp, "<foo>\n<!-- this is a comment -->\n</foo>", "\n\n");
           testContentMerging(pp, "<foo><!-- this is a comment -->\n</foo>", "\n");
  +        testContentMerging(pp, "<foo>al<!-- this is a comment -->ek\n</foo>", "alek\n");
  +        testContentMerging(pp, "<foo>a<!-- sdds \n>-->l\n<!-- this is a comment -->ek\n</foo>", "al\nek\n");
       }
   
       public void testContentMerging(final XmlPullParser pp, final String xml, final String expected)
  @@ -300,6 +302,56 @@
           pp.require( pp.END_TAG, null, "foo");
       }
   
  +    public void testComments2() throws Exception {
  +         testComments2(" <b>\r\n</b>\n ", " <b>\n</b>\n ");
  +         testComments2(" <b>\r\n</b>\r\n ", " <b>\n</b>\n ");
  +         testComments2(" <b>\r\n</b>\r\n", " <b>\n</b>\n");
  +         testComments2(" <b>\r\n</b>\r\n\r\n", " <b>\n</b>\n\n");
  +         testComments2("\r\n<b>\n</b>\n ", "\n<b>\n</b>\n ");
  +         testComments2("<b>\r</b>\n ", "<b>\n</b>\n ");
  +         testComments2("<b>\n</b>\r", "<b>\n</b>\n");
  +         testComments2("<b>\r\n</b>","<b>\n</b>");
  +         testComments2("<b>\r\n ? </b>","<b>\n ? </b>");
  +
  +         testComments2("\n <b>\n</b>\n ");
  +         testComments2("\n<b>\n</b>\n ");
  +         testComments2(" <b>\n</b>\n ");
  +         testComments2("<b>\n</b>\n ");
  +         testComments2("<b>\n</b>\n");
  +         testComments2("<b>\n</b>");
  +         testComments2("<b>- -</b>");
  +         testComments2("<b>/b>");
  +         testComments2("<b>?? ?/b>");
  +         testComments2("<?po <b>?? ?/b ?>");
  +    }
  +
  +    public void testComments2(String value) throws Exception {
  +        testComments2(value, value);
  +    }
  +
  +    public void testComments2(String value, String expected) throws Exception {
  +        XmlPullParser pp = factory.newPullParser();
  +        final String XML = "<foo>\n<!--"+value+"-->\n</foo>";
  +        testContentMerging(pp, XML, "\n\n");
  +        pp.setInput( new StringReader( XML ) );
  +        pp.require( XmlPullParser.START_DOCUMENT, null, null);
  +        pp.next();
  +        pp.require( XmlPullParser.START_TAG, null, "foo");
  +        pp.nextToken();
  +        pp.require( XmlPullParser.TEXT, null, null);
  +        assertEquals("\n", pp.getText());
  +        pp.nextToken();
  +        pp.require( XmlPullParser.COMMENT, null, null);
  +        //System.err.println(getClass()+" expected="+printable(expected)+" text="+printable(pp.getText()));
  +        assertEquals(printable(expected), printable(pp.getText()));
  +        assertEquals(expected, pp.getText());
  +        pp.nextToken();
  +        pp.require( XmlPullParser.TEXT, null, null);
  +        assertEquals("\n", pp.getText());
  +        pp.nextToken();
  +        pp.require( XmlPullParser.END_TAG, null, "foo");
  +    }
  +
   
       public void testPI() throws Exception {
           XmlPullParser pp = factory.newPullParser();
  @@ -337,6 +389,62 @@
   
       }
   
  +    public void testPi2() throws Exception {
  +         testPi2("<b>\r\n</b>\n ", "<b>\n</b>\n ");
  +         testPi2("<b>\r\n</b>\r\n ", "<b>\n</b>\n ");
  +         testPi2("<b>\r\n</b>\r\n", "<b>\n</b>\n");
  +         testPi2("<b>\r\n</b>\r\n\r\n", "<b>\n</b>\n\n");
  +         testPi2("\r\n<b>\n</b>\n ", "\n<b>\n</b>\n ");
  +         testPi2("<b>\r</b>\n ", "<b>\n</b>\n ");
  +         testPi2("<b>\n</b>\r", "<b>\n</b>\n");
  +         testPi2("<b>\r\n</b>","<b>\n</b>");
  +
  +         testPi2("\n <b>\n</b>\n ");
  +         testPi2("\n<b>\n</b>\n ");
  +         testPi2(" <b>\n</b>\n ");
  +         testPi2("<b>\n</b>\n ");
  +         testPi2("<b>\n</b>\n");
  +         testPi2("<b>\n</b>");
  +         testPi2("<b>- -</b>");
  +         testPi2("<b>/b>");
  +         testPi2("<b><!-- -->cx-</b>");
  +         testPi2("<b><!-- --? ?- ?? ? ></b>");
  +    }
  +
  +    public void testPi2(String value) throws Exception {
  +        testPi2("pi", value, value);
  +    }
  +
  +    public void testPi2(String value, String expected) throws Exception {
  +        testPi2("pi", value, expected);
  +    }
  +
  +    public void testPi2(String target, String value, String expected) throws Exception {
  +        XmlPullParser pp = factory.newPullParser();
  +        if(target != null) {
  +            value = "pi "+value;
  +            expected = "pi "+expected;
  +        }
  +        final String XML = "<foo>\n<?"+value+"?>\n</foo>";
  +        testContentMerging(pp, XML, "\n\n");
  +        pp.setInput( new StringReader( XML ) );
  +        pp.require( XmlPullParser.START_DOCUMENT, null, null);
  +        pp.next();
  +        pp.require( XmlPullParser.START_TAG, null, "foo");
  +        pp.nextToken();
  +        pp.require( XmlPullParser.TEXT, null, null);
  +        assertEquals("\n", pp.getText());
  +        pp.nextToken();
  +        pp.require( XmlPullParser.PROCESSING_INSTRUCTION, null, null);
  +        //System.err.println(getClass()+" expected="+printable(expected)+" text="+printable(pp.getText()));
  +        assertEquals(printable(expected), printable(pp.getText()));
  +        assertEquals(expected, pp.getText());
  +        pp.nextToken();
  +        pp.require( XmlPullParser.TEXT, null, null);
  +        assertEquals("\n", pp.getText());
  +        pp.nextToken();
  +        pp.require( XmlPullParser.END_TAG, null, "foo");
  +    }
   
       public void testReportNamespaceAttributes() throws Exception {
           XmlPullParser pp = factory.newPullParser();
  
  
  


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Looking for the latest Free IT White Papers?
Visit SearchMobileComputing.com to access over 500 white papers.
Get instant access at SearchMobileComputing.com Today
http://us.click.yahoo.com/HgVXVB/PLNGAA/xitMAA/2U_rlB/TM
---------------------------------------------------------------------~->

To unsubscribe from this group, send an email to:
[email protected]

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/