@@ -128,23 +128,47 @@ fn test_incomplete_row_parsing() {
128128
129129 let mut parser = Parser :: new ( ) ;
130130 parser. chunk ( & real_input. clone ( ) , 0 ) . unwrap ( ) ;
131- let mut snap = vec ! [ ] ;
131+ let mut parse_snap = vec ! [ ] ;
132+
132133 loop {
133134 match parser. parse_many ( & alloc) {
134- Ok ( ( begin , chunk) ) => {
135+ Ok ( ( _ , chunk) ) => {
135136 if chunk. len ( ) == 0 {
136137 break ;
137138 }
138139 for ( doc, next_offset) in chunk {
139- snap . push ( ( begin , next_offset, doc. to_debug_json_value ( ) ) ) ;
140+ parse_snap . push ( ( next_offset, doc. to_debug_json_value ( ) ) ) ;
140141 }
141142 }
142143 Err ( ( err, location) ) => {
143- snap . push ( ( - 1 , -1 , json ! ( format!( "{err} @ {location:?}" ) ) ) ) ;
144+ parse_snap . push ( ( -1 , json ! ( format!( "{err} @ {location:?}" ) ) ) ) ;
144145 }
145146 }
146147 }
147- snaps. push ( ( String :: from_utf8 ( real_input) . unwrap ( ) , snap) ) ;
148+
149+ let mut parser = Parser :: new ( ) ;
150+ parser. chunk ( & real_input. clone ( ) , 0 ) . unwrap ( ) ;
151+ let mut transcode_snap = vec ! [ ] ;
152+
153+ loop {
154+ match parser. transcode_many ( Default :: default ( ) ) {
155+ Ok ( transcoded) => {
156+ if transcoded. is_empty ( ) {
157+ break ;
158+ }
159+ for ( doc, next_offset) in transcoded. into_iter ( ) {
160+ transcode_snap. push ( ( next_offset, doc. get ( ) . to_debug_json_value ( ) ) ) ;
161+ }
162+ }
163+ Err ( ( err, location) ) => {
164+ transcode_snap. push ( ( -1 , json ! ( format!( "{err} @ {location:?}" ) ) ) ) ;
165+ }
166+ }
167+ }
168+
169+ debug_assert_eq ! ( parse_snap, transcode_snap) ;
170+
171+ snaps. push ( ( String :: from_utf8 ( real_input) . unwrap ( ) , parse_snap) ) ;
148172 }
149173
150174 insta:: assert_debug_snapshot!( snaps, @r###"
@@ -153,12 +177,10 @@ fn test_incomplete_row_parsing() {
153177 "st\": {\"this\": \"is\", \"a\": \"doc\"}}\n{\"this\": \"is a real doc\"}\n",
154178 [
155179 (
156- -1,
157180 -1,
158181 String("expected value at line 1 column 1 @ 0..33"),
159182 ),
160183 (
161- 33,
162184 59,
163185 Object {
164186 "this": String("is a real doc"),
@@ -170,12 +192,10 @@ fn test_incomplete_row_parsing() {
170192 "\"test\": {\"this\": \"is\", \"a\": \"doc\"}}\n{\"this\": \"is a real doc\"}\n",
171193 [
172194 (
173- -1,
174195 -1,
175196 String("incomplete row @ 0..45"),
176197 ),
177198 (
178- 0,
179199 62,
180200 Object {
181201 "this": String("is a real doc"),
@@ -187,12 +207,10 @@ fn test_incomplete_row_parsing() {
187207 "{\"test\": 5}, {\"test\": 6\"}]\n{\"this\": \"is a real doc\"}\n",
188208 [
189209 (
190- -1,
191210 -1,
192211 String("incomplete row @ 0..33"),
193212 ),
194213 (
195- 0,
196214 53,
197215 Object {
198216 "this": String("is a real doc"),
@@ -204,14 +222,12 @@ fn test_incomplete_row_parsing() {
204222 "{\"real\": \"object\"}\n{\"this\": \"is a real doc\"}\n",
205223 [
206224 (
207- 0,
208225 19,
209226 Object {
210227 "real": String("object"),
211228 },
212229 ),
213230 (
214- 0,
215231 45,
216232 Object {
217233 "this": String("is a real doc"),
0 commit comments