()
| 1355 | |
| 1356 | #[test] |
| 1357 | fn test_format_items_no_truncate() -> Result<()> { |
| 1358 | let config = LintExecutionConfig { no_truncate: true }; |
| 1359 | let header = "Test Header"; |
| 1360 | let mut output_str = String::new(); |
| 1361 | |
| 1362 | // Test case 1: Empty iterator |
| 1363 | let items_empty: Vec<String> = vec![]; |
| 1364 | format_items(&config, header, items_empty.iter(), &mut output_str)?; |
| 1365 | assert_eq!(output_str, ""); |
| 1366 | output_str.clear(); |
| 1367 | |
| 1368 | // Test case 2: Iterator with one item |
| 1369 | let items_one = ["item1"]; |
| 1370 | format_items(&config, header, items_one.iter(), &mut output_str)?; |
| 1371 | assert_eq!(output_str, "Test Header:\n item1\n"); |
| 1372 | output_str.clear(); |
| 1373 | |
| 1374 | // Test case 3: Iterator with multiple items |
| 1375 | let items_multiple = (1..=3).map(|v| format!("item{v}")).collect::<Vec<_>>(); |
| 1376 | format_items(&config, header, items_multiple.iter(), &mut output_str)?; |
| 1377 | assert_eq!(output_str, "Test Header:\n item1\n item2\n item3\n"); |
| 1378 | output_str.clear(); |
| 1379 | |
| 1380 | // Test case 4: Iterator with items > DEFAULT_TRUNCATED_OUTPUT |
| 1381 | let items_multiple = (1..=8).map(|v| format!("item{v}")).collect::<Vec<_>>(); |
| 1382 | format_items(&config, header, items_multiple.iter(), &mut output_str)?; |
| 1383 | assert_eq!( |
| 1384 | output_str, |
| 1385 | "Test Header:\n item1\n item2\n item3\n item4\n item5\n item6\n item7\n item8\n" |
| 1386 | ); |
| 1387 | output_str.clear(); |
| 1388 | |
| 1389 | Ok(()) |
| 1390 | } |
| 1391 | |
| 1392 | #[test] |
| 1393 | fn test_format_items_truncate() -> Result<()> { |
nothing calls this directly
no test coverage detected