@@ -43,11 +43,13 @@ public void testGetValueAsText() throws IOException {
4343 assertThat (parser .nextFieldName (), Matchers .equalTo ("foo" ));
4444 assertThat (parser .nextValue (), Matchers .equalTo (JsonToken .VALUE_STRING ));
4545
46- var textRef = parser .getValueAsText ().bytes ();
47- assertThat (textRef , Matchers .notNullValue ());
48- assertThat (textRef .offset (), Matchers .equalTo (9 ));
49- assertThat (textRef .offset () + textRef .length (), Matchers .equalTo (12 ));
50- assertTextRef (textRef , "bar" );
46+ var text = parser .getValueAsText ();
47+ assertThat (text , Matchers .notNullValue ());
48+
49+ var bytes = text .bytes ();
50+ assertThat (bytes .offset (), Matchers .equalTo (9 ));
51+ assertThat (bytes .offset () + bytes .length (), Matchers .equalTo (12 ));
52+ assertTextRef (bytes , "bar" );
5153
5254 assertThat (parser .getValueAsString (), Matchers .equalTo ("bar" ));
5355 assertThat (parser .getValueAsText (), Matchers .nullValue ());
@@ -60,9 +62,9 @@ public void testGetValueAsText() throws IOException {
6062 assertThat (parser .nextFieldName (), Matchers .equalTo ("foo" ));
6163 assertThat (parser .nextValue (), Matchers .equalTo (JsonToken .VALUE_STRING ));
6264
63- var textRef = parser .getValueAsText ();
64- assertThat (textRef , Matchers .notNullValue ());
65- assertTextRef (textRef .bytes (), "bar\" baz\" " );
65+ var text = parser .getValueAsText ();
66+ assertThat (text , Matchers .notNullValue ());
67+ assertTextRef (text .bytes (), "bar\" baz\" " );
6668 });
6769
6870 testParseJson ("{\" foo\" : \" b\\ u00e5r\" }" , parser -> {
@@ -79,8 +81,17 @@ public void testGetValueAsText() throws IOException {
7981 assertThat (parser .nextFieldName (), Matchers .equalTo ("foo" ));
8082 assertThat (parser .nextValue (), Matchers .equalTo (JsonToken .VALUE_STRING ));
8183
82- assertThat (parser .getValueAsText (), Matchers .nullValue ());
84+ var text = parser .getValueAsText ();
85+ assertThat (text , Matchers .notNullValue ());
86+
87+ var bytes = text .bytes ();
88+ assertThat (bytes .offset (), Matchers .equalTo (9 ));
89+ assertThat (bytes .offset () + bytes .length (), Matchers .equalTo (13 ));
90+ assertTextRef (bytes , "bår" );
91+
8392 assertThat (parser .getValueAsString (), Matchers .equalTo ("bår" ));
93+
94+ assertThat (parser .nextToken (), Matchers .equalTo (JsonToken .END_OBJECT ));
8495 });
8596
8697 testParseJson ("{\" foo\" : [\" lorem\" , \" ipsum\" , \" dolor\" ]}" , parser -> {
@@ -169,7 +180,6 @@ private TestInput buildRandomInput(int length) {
169180 var value = Character .toChars (randomCodepoint (false ));
170181 input .append (value );
171182 result .append (value );
172- doesSupportOptimized = false ;
173183 }
174184 }
175185 } else {
0 commit comments