public void testParsingOfLongerSequences() throws Exception {
  double[] values=new double[]{0.01,-10.5,2.1e9,4.0e-8};
  StringBuilder sb=new StringBuilder();
  for (int i=0; i < values.length; ++i) {
    if (i > 0) {
      sb.append(',');
    }
    sb.append(values[i]);
  }
  String segment=sb.toString();
  int COUNT=1000;
  sb=new StringBuilder(COUNT * segment.length() + 20);
  sb.append("[");
  for (int i=0; i < COUNT; ++i) {
    if (i > 0) {
      sb.append(',');
    }
    sb.append(segment);
    sb.append('\n');
    int x=(i & 3);
    if (i > 300) {
      x+=i % 5;
    }
    while (--x > 0) {
      sb.append(' ');
    }
  }
  sb.append("]");
  String DOC=sb.toString();
  for (int input=0; input < 2; ++input) {
    JsonParser jp;
    if (input == 0) {
      jp=createParserUsingStream(DOC,"UTF-8");
    }
 else {
      jp=createParserUsingReader(DOC);
    }
    assertToken(JsonToken.START_ARRAY,jp.nextToken());
    for (int i=0; i < COUNT; ++i) {
      for (      double d : values) {
        assertToken(JsonToken.VALUE_NUMBER_FLOAT,jp.nextToken());
        assertEquals(d,jp.getDoubleValue());
      }
    }
    assertToken(JsonToken.END_ARRAY,jp.nextToken());
  }
}

public void testParsingOfLongerSequences ( ) throws Exception { double [ ] values = new double [ ] { 0.01 , - 10.5 , 2.1e9 , 4.0e-8 } ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < values . length ; ++ i ) { if ( i > 0 ) { sb . append ( ',' ) ; } sb . append ( values [ i ] ) ; } String segment = sb . toString ( ) ; int COUNT = 1000 ; sb = new StringBuilder ( COUNT * segment . length ( ) + 20 ) ; sb . append ( "[" ) ; for ( int i = 0 ; i < COUNT ; ++ i ) { if ( i > 0 ) { sb . append ( ',' ) ; } sb . append ( segment ) ; sb . append ( '\n' ) ; int x = ( i & 3 ) ; if ( i > 300 ) { x += i % 5 ; } while ( -- x > 0 ) { sb . append ( ' ' ) ; } } sb . append ( "]" ) ; String DOC = sb . toString ( ) ; for ( int input = 0 ; input < 2 ; ++ input ) { JsonParser jp ; if ( input == 0 ) { jp = createParserUsingStream ( DOC , "UTF-8" ) ; } else { jp = createParserUsingReader ( DOC ) ; } assertToken ( JsonToken . START_ARRAY , jp . nextToken ( ) ) ; for ( int i = 0 ; i < COUNT ; ++ i ) { for ( double d : values ) { assertToken ( JsonToken . VALUE_NUMBER_FLOAT , jp . nextToken ( ) ) ; assertEquals ( d , jp . getDoubleValue ( ) ) ; } } assertToken ( JsonToken . END_ARRAY , jp . nextToken ( ) ) ; } }
method that tries to test that number parsing works in cases where input is split between buffer boundaries .
