@@ -1301,67 +1301,38 @@ mod tests {
13011301 ] ,
13021302 )
13031303 . await ;
1304+ assert ! (
1305+ result. is_ok( ) ,
1306+ "test_flow_function failed: {:?}" ,
1307+ result. err( )
1308+ ) ;
13041309 let value = result. unwrap ( ) ;
13051310 match value {
13061311 Value :: KTable ( table) => {
1307- let chunks: Vec < ( & str , RangeValue ) > = table
1308- . iter ( )
1309- . map ( |( k, v) | {
1310- let text = v. 0 . fields [ 0 ] . as_str ( ) . unwrap ( ) ;
1311- let range = match & k. 0 [ 0 ] {
1312- KeyPart :: Range ( r) => r. clone ( ) ,
1313- _ => panic ! ( "Expected KeyPart to be a Range" ) ,
1314- } ;
1315- ( text. as_ref ( ) , range)
1316- } )
1317- . collect ( ) ;
1318-
1319- assert ! ( chunks. contains( & ( "First chunk." , RangeValue :: new( 3 , 16 ) ) ) ) ;
1320- assert ! ( chunks. contains( & (
1321- "Second chunk with spaces at the end." ,
1322- RangeValue :: new( 22 , 59 )
1323- ) ) ) ;
1312+ assert_eq ! ( table. len( ) , 3 ) ;
1313+
1314+ let expected_chunks = vec ! [
1315+ ( RangeValue :: new( 3 , 16 ) , " First chunk." ) ,
1316+ ( RangeValue :: new( 19 , 45 ) , " Second chunk with spaces" ) ,
1317+ ( RangeValue :: new( 46 , 57 ) , "at the end." ) ,
1318+ ] ;
1319+
1320+ for ( range, expected_text) in expected_chunks {
1321+ let key = KeyValue :: from_single_part ( range) ;
1322+ match table. get ( & key) {
1323+ Some ( scope_value_ref) => {
1324+ let chunk_text =
1325+ scope_value_ref. 0 . fields [ 0 ] . as_str ( ) . unwrap_or_else ( |_| {
1326+ panic ! ( "Chunk text not a string for key {key:?}" )
1327+ } ) ;
1328+ assert_eq ! ( * * chunk_text, * expected_text) ;
1329+ }
1330+ None => panic ! ( "Expected row value for key {key:?}, not found" ) ,
1331+ }
1332+ }
13241333 }
13251334 other => panic ! ( "Expected Value::KTable, got {other:?}" ) ,
13261335 }
13271336 }
13281337 }
1329-
1330- #[ tokio:: test]
1331- async fn test_deeply_nested_structure_no_stack_overflow ( ) {
1332- let spec = Spec {
1333- custom_languages : vec ! [ ] ,
1334- } ;
1335- let factory = Arc :: new ( Factory ) ;
1336- let input_arg_schemas = & build_split_recursively_arg_schemas ( ) ;
1337-
1338- let deep_text = format ! ( "{}{}{}" , "(" . repeat( 500 ) , "some text" , ")" . repeat( 500 ) ) ;
1339- let language = "C++" ;
1340-
1341- let result = test_flow_function (
1342- & factory,
1343- & spec,
1344- input_arg_schemas,
1345- vec ! [
1346- deep_text. into( ) ,
1347- ( 20i64 ) . into( ) ,
1348- ( 5i64 ) . into( ) ,
1349- ( 0i64 ) . into( ) ,
1350- language. to_string( ) . into( ) ,
1351- ] ,
1352- )
1353- . await ;
1354-
1355- assert ! (
1356- result. is_ok( ) ,
1357- "The function should not panic or crash on deeply nested input."
1358- ) ;
1359-
1360- if let Ok ( Value :: KTable ( table) ) = result {
1361- assert ! (
1362- !table. is_empty( ) ,
1363- "It should have produced at least one chunk."
1364- ) ;
1365- }
1366- }
13671338}
0 commit comments