Author: fanningpj Date: Wed Nov 22 09:57:45 2017 New Revision: 1816020 URL: http://svn.apache.org/viewvc?rev=1816020&view=rev Log: add TestStringCodepointsIterable
Added: poi/trunk/src/testcases/org/apache/poi/util/TestStringCodepointsIterable.java - copied, changed from r1815997, poi/trunk/src/testcases/org/apache/poi/util/TestStaxHelper.java Copied: poi/trunk/src/testcases/org/apache/poi/util/TestStringCodepointsIterable.java (from r1815997, poi/trunk/src/testcases/org/apache/poi/util/TestStaxHelper.java) URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/util/TestStringCodepointsIterable.java?p2=poi/trunk/src/testcases/org/apache/poi/util/TestStringCodepointsIterable.java&p1=poi/trunk/src/testcases/org/apache/poi/util/TestStaxHelper.java&r1=1815997&r2=1816020&rev=1816020&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/util/TestStaxHelper.java (original) +++ poi/trunk/src/testcases/org/apache/poi/util/TestStringCodepointsIterable.java Wed Nov 22 09:57:45 2017 @@ -17,47 +17,28 @@ package org.apache.poi.util; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamException; +import java.util.ArrayList; +import java.util.List; +import org.junit.Assert; import org.junit.Test; /** - * Unit test for StaxHelper + * Unit test for StringCodepointsIterable */ -public class TestStaxHelper { - - /** - * test that newXMLInputFactory returns a factory with sensible defaults - */ - @Test - public void testNewXMLInputFactory() throws XMLStreamException { - XMLInputFactory factory = StaxHelper.newXMLInputFactory(); - assertEquals(true, factory.getProperty(XMLInputFactory.IS_NAMESPACE_AWARE)); - assertEquals(false, factory.getProperty(XMLInputFactory.IS_VALIDATING)); - assertEquals(false, factory.getProperty(XMLInputFactory.SUPPORT_DTD)); - assertEquals(false, factory.getProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES)); - } - - /** - * test that newXMLOutputFactory returns a factory with sensible defaults - */ - @Test - public void testNewXMLOutputFactory() { - XMLOutputFactory factory = StaxHelper.newXMLOutputFactory(); - assertEquals(true, factory.getProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES)); - } +public class TestStringCodepointsIterable { - /** - * test that newXMLEventFactory returns a factory - */ @Test - public void testNewXMLEventFactory() { - assertNotNull(StaxHelper.newXMLEventFactory()); + public void testIterable() { + final String unicodeSurrogates = "\uD835\uDF4A\uD835\uDF4B\uD835\uDF4C\uD835\uDF4D\uD835\uDF4E" + + "abcdef123456"; + StringCodepointsIterable sci = new StringCodepointsIterable(unicodeSurrogates); + List<String> codePoints = new ArrayList<>(); + List<String> codePoints2 = new ArrayList<>(); + sci.iterator().forEachRemaining(codePoints::add); + sci.iterator().forEachRemaining(codePoints2::add); + Assert.assertEquals(17, codePoints.size()); + Assert.assertEquals(codePoints, codePoints2); } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@poi.apache.org For additional commands, e-mail: commits-h...@poi.apache.org