shlesha 0.5.7

High-performance extensible transliteration library with hub-and-spoke architecture
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
use shlesha::Shlesha;
use std::collections::HashMap;

/// All supported scripts based on schema files
const ALL_SCRIPTS: &[&str] = &[
    // Roman scripts
    "iast",
    "slp1",
    "harvard_kyoto",
    "itrans",
    "velthuis",
    "wx",
    "kolkata",
    // Indic scripts
    "devanagari",
    "bengali",
    "gujarati",
    "gurmukhi",
    "kannada",
    "malayalam",
    "odia",
    "tamil",
    "telugu",
    "grantha",
    "sinhala",
];

const ROMAN_SCRIPTS: &[&str] = &[
    "iast",
    "slp1",
    "harvard_kyoto",
    "itrans",
    "velthuis",
    "wx",
    "kolkata",
];

const INDIC_SCRIPTS: &[&str] = &[
    "devanagari",
    "bengali",
    "gujarati",
    "gurmukhi",
    "kannada",
    "malayalam",
    "odia",
    "tamil",
    "telugu",
    "grantha",
    "sinhala",
];

/// Test data for each script type
#[derive(Debug, Clone)]
struct TestCase {
    text: &'static str,
    script: &'static str,
    description: &'static str,
}

impl TestCase {
    fn new(text: &'static str, script: &'static str, description: &'static str) -> Self {
        Self {
            text,
            script,
            description,
        }
    }
}

/// Get test cases for comprehensive testing
fn get_test_cases() -> Vec<TestCase> {
    vec![
        // IAST test cases
        TestCase::new("saṃskṛtam", "iast", "basic Sanskrit word"),
        TestCase::new("dharmakṣetre", "iast", "word with kṣ combination"),
        TestCase::new("namaskāram", "iast", "word with long vowels"),
        TestCase::new("ā", "iast", "single long vowel"),
        TestCase::new("ṛ", "iast", "vocalic r"),
        TestCase::new("ṃ", "iast", "anusvara"),
        TestCase::new("ḥ", "iast", "visarga"),
        TestCase::new("kṣ", "iast", "conjunct consonant"),
        TestCase::new("jñ", "iast", "nasal conjunct"),
        // SLP1 test cases
        TestCase::new("saMskftam", "slp1", "basic Sanskrit word in SLP1"),
        TestCase::new("Darmakzetre", "slp1", "word with kz combination"),
        TestCase::new("namaskAram", "slp1", "word with long vowels in SLP1"),
        TestCase::new("A", "slp1", "single long vowel A"),
        TestCase::new("f", "slp1", "vocalic r in SLP1"),
        TestCase::new("M", "slp1", "anusvara in SLP1"),
        TestCase::new("H", "slp1", "visarga in SLP1"),
        TestCase::new("kz", "slp1", "conjunct kṣ in SLP1"),
        TestCase::new("jY", "slp1", "nasal conjunct in SLP1"),
        // Harvard-Kyoto test cases
        TestCase::new("saMskRtam", "harvard_kyoto", "basic Sanskrit word in HK"),
        TestCase::new("dharmakSetram", "harvard_kyoto", "word with kS combination"),
        TestCase::new("namaskAram", "harvard_kyoto", "word with long vowels in HK"),
        TestCase::new("A", "harvard_kyoto", "single long vowel A"),
        TestCase::new("R", "harvard_kyoto", "vocalic r in HK"),
        TestCase::new("M", "harvard_kyoto", "anusvara in HK"),
        TestCase::new("H", "harvard_kyoto", "visarga in HK"),
        TestCase::new("kS", "harvard_kyoto", "conjunct kṣ in HK"),
        TestCase::new("jJ", "harvard_kyoto", "nasal conjunct in HK"),
        // Devanagari test cases
        TestCase::new("संस्कृतम्", "devanagari", "basic Sanskrit word in Devanagari"),
        TestCase::new("धर्मक्षेत्रे", "devanagari", "word with क्ष in Devanagari"),
        TestCase::new("नमस्कारम्", "devanagari", "greeting in Devanagari"),
        // Telugu test cases
        TestCase::new("సంస్కృతం", "telugu", "Sanskrit word in Telugu"),
        TestCase::new("నమస్కారం", "telugu", "greeting in Telugu"),
        // ITRANS test cases (following ITRANS 5.3 standard)
        TestCase::new("a", "itrans", "basic vowel"),
        TestCase::new("aa", "itrans", "long vowel A"),
        TestCase::new("i", "itrans", "short i vowel"),
        TestCase::new("ii", "itrans", "long I vowel"),
        TestCase::new("u", "itrans", "short u vowel"),
        TestCase::new("uu", "itrans", "long U vowel"),
        TestCase::new("RRi", "itrans", "vocalic r"),
        TestCase::new("ka", "itrans", "basic consonant"),
        TestCase::new("M", "itrans", "anusvara"),
        TestCase::new("H", "itrans", "visarga"),
        TestCase::new("kSha", "itrans", "conjunct kṣ"),
        TestCase::new("j~na", "itrans", "conjunct jñ"),
        // Velthuis test cases
        TestCase::new("a", "velthuis", "basic vowel"),
        TestCase::new("aa", "velthuis", "long vowel A"),
        TestCase::new("i", "velthuis", "short i vowel"),
        TestCase::new("ii", "velthuis", "long I vowel"),
        TestCase::new("u", "velthuis", "short u vowel"),
        TestCase::new("uu", "velthuis", "long U vowel"),
        TestCase::new(".r", "velthuis", "vocalic r"),
        TestCase::new("ka", "velthuis", "basic consonant"),
        TestCase::new(".m", "velthuis", "anusvara"),
        TestCase::new(".h", "velthuis", "visarga"),
        TestCase::new("k.sa", "velthuis", "conjunct kṣ"),
        // WX test cases (following WX notation)
        TestCase::new("a", "wx", "basic vowel"),
        TestCase::new("A", "wx", "long vowel A"),
        TestCase::new("i", "wx", "short i vowel"),
        TestCase::new("I", "wx", "long I vowel"),
        TestCase::new("u", "wx", "short u vowel"),
        TestCase::new("U", "wx", "long U vowel"),
        TestCase::new("q", "wx", "vocalic r"),
        TestCase::new("ka", "wx", "basic consonant"),
        TestCase::new("M", "wx", "anusvara"),
        TestCase::new("H", "wx", "visarga"),
        TestCase::new("kRa", "wx", "conjunct kṣ"),
        // Kolkata test cases
        TestCase::new("a", "kolkata", "basic vowel"),
        TestCase::new("aa", "kolkata", "long vowel A"),
        TestCase::new("i", "kolkata", "short i vowel"),
        TestCase::new("ii", "kolkata", "long I vowel"),
        TestCase::new("u", "kolkata", "short u vowel"),
        TestCase::new("uu", "kolkata", "long U vowel"),
        TestCase::new("ri", "kolkata", "vocalic r"),
        TestCase::new("ka", "kolkata", "basic consonant"),
        TestCase::new("ng", "kolkata", "anusvara"),
        TestCase::new("h", "kolkata", "visarga"),
        // Simple test cases for coverage
        TestCase::new("om", "iast", "simple word"),
        TestCase::new("ka", "iast", "single consonant"),
        TestCase::new("a", "iast", "single vowel"),
    ]
}

#[test]
fn test_all_scripts_are_supported() {
    let shlesha = Shlesha::new();
    let supported_scripts = shlesha.list_supported_scripts();

    println!("Supported scripts: {:?}", supported_scripts);

    let mut missing_scripts = Vec::new();
    for script in ALL_SCRIPTS {
        if !supported_scripts.contains(&script.to_string()) {
            missing_scripts.push(*script);
        }
    }

    if !missing_scripts.is_empty() {
        println!("Missing scripts: {:?}", missing_scripts);
        // Don't fail the test, just document what's missing
    }

    // Ensure we have at least the core scripts
    let core_scripts = ["iast", "slp1", "devanagari"];
    for script in core_scripts {
        assert!(
            supported_scripts.contains(&script.to_string()),
            "Core script '{}' should be supported",
            script
        );
    }
}

#[test]
fn test_identity_conversions_all_scripts() {
    let shlesha = Shlesha::new();
    let supported_scripts = shlesha.list_supported_scripts();

    let test_cases = get_test_cases();
    let mut failures = Vec::new();

    for test_case in &test_cases {
        if !supported_scripts.contains(&test_case.script.to_string()) {
            continue; // Skip unsupported scripts
        }

        match shlesha.transliterate(test_case.text, test_case.script, test_case.script) {
            Ok(result) => {
                if result != test_case.text {
                    failures.push(format!(
                        "Identity conversion failed for {} '{}': got '{}'",
                        test_case.script, test_case.text, result
                    ));
                }
            }
            Err(e) => {
                failures.push(format!(
                    "Identity conversion error for {} '{}': {}",
                    test_case.script, test_case.text, e
                ));
            }
        }
    }

    if !failures.is_empty() {
        for failure in &failures {
            println!("IDENTITY FAILURE: {}", failure);
        }
        panic!("Identity conversion failures: {}", failures.len());
    }
}

#[test]
fn test_roman_to_roman_conversions() {
    let shlesha = Shlesha::new();
    let supported_scripts = shlesha.list_supported_scripts();

    // Filter to supported Roman scripts
    let available_roman: Vec<&str> = ROMAN_SCRIPTS
        .iter()
        .filter(|script| supported_scripts.contains(&script.to_string()))
        .copied()
        .collect();

    let mut conversion_matrix = HashMap::new();
    let mut failures = Vec::new();

    // Test all Roman-to-Roman conversions
    for &source in &available_roman {
        for &target in &available_roman {
            if source == target {
                continue; // Skip identity conversions (tested separately)
            }

            let mut conversions_tested = 0;
            let mut conversions_succeeded = 0;

            // Get test cases specific to the source script
            let source_test_cases: Vec<_> = get_test_cases()
                .into_iter()
                .filter(|tc| tc.script == source)
                .collect();

            // If no specific test cases, use basic ones
            let test_cases = if source_test_cases.is_empty() {
                vec![
                    TestCase::new("a", source, "basic vowel"),
                    TestCase::new("ka", source, "basic consonant"),
                ]
            } else {
                source_test_cases
            };

            for test_case in &test_cases {
                conversions_tested += 1;

                // Use the script-specific test data directly
                let source_text = test_case.text;

                // Convert from source to target
                match shlesha.transliterate(source_text, source, target) {
                    Ok(result) => {
                        conversions_succeeded += 1;
                        println!("✓ {}→{}: '{}' → '{}'", source, target, source_text, result);
                    }
                    Err(e) => {
                        failures.push(format!(
                            "{}→{}: '{}' failed - {}",
                            source, target, source_text, e
                        ));
                    }
                }
            }

            conversion_matrix.insert(
                (source, target),
                (conversions_succeeded, conversions_tested),
            );
        }
    }

    // Print conversion matrix
    println!("\n📊 Roman-to-Roman Conversion Matrix:");
    println!("{:<15} {}", "Source→Target", "Success/Total");
    println!("{}", "-".repeat(40));

    for &source in &available_roman {
        for &target in &available_roman {
            if source != target {
                if let Some((succeeded, total)) = conversion_matrix.get(&(source, target)) {
                    let percentage = if *total > 0 {
                        succeeded * 100 / total
                    } else {
                        0
                    };
                    println!(
                        "{:<15} {}/{} ({}%)",
                        format!("{}→{}", source, target),
                        succeeded,
                        total,
                        percentage
                    );
                }
            }
        }
    }

    if !failures.is_empty() {
        println!("\n❌ Roman-to-Roman conversion failures:");
        for failure in &failures[..failures.len().min(10)] {
            println!("  {}", failure);
        }
        if failures.len() > 10 {
            println!("  ... and {} more failures", failures.len() - 10);
        }
    }

    // Don't fail the test, just report the issues
}

#[test]
fn test_indic_to_indic_conversions() {
    let shlesha = Shlesha::new();
    let supported_scripts = shlesha.list_supported_scripts();

    // Filter to supported Indic scripts
    let available_indic: Vec<&str> = INDIC_SCRIPTS
        .iter()
        .filter(|script| supported_scripts.contains(&script.to_string()))
        .copied()
        .collect();

    let mut conversion_matrix = HashMap::new();
    let mut failures = Vec::new();

    // Test all Indic-to-Indic conversions
    for &source in &available_indic {
        for &target in &available_indic {
            if source == target {
                continue;
            }

            let mut conversions_tested = 0;
            let mut conversions_succeeded = 0;

            // Use Devanagari test cases as the baseline
            let devanagari_test_cases: Vec<_> = get_test_cases()
                .into_iter()
                .filter(|tc| tc.script == "devanagari")
                .collect();

            for test_case in &devanagari_test_cases {
                conversions_tested += 1;

                // Convert from Devanagari to source script (if needed)
                let source_text = if source == "devanagari" {
                    test_case.text.to_string()
                } else {
                    match shlesha.transliterate(test_case.text, "devanagari", source) {
                        Ok(text) => text,
                        Err(e) => {
                            failures.push(format!(
                                "Preparation failed: Devanagari→{}: '{}' - {}",
                                source, test_case.text, e
                            ));
                            continue;
                        }
                    }
                };

                // Then convert from source to target
                match shlesha.transliterate(&source_text, source, target) {
                    Ok(result) => {
                        conversions_succeeded += 1;
                        println!("✓ {}→{}: '{}' → '{}'", source, target, source_text, result);
                    }
                    Err(e) => {
                        failures.push(format!(
                            "{}→{}: '{}' failed - {}",
                            source, target, source_text, e
                        ));
                    }
                }
            }

            conversion_matrix.insert(
                (source, target),
                (conversions_succeeded, conversions_tested),
            );
        }
    }

    // Print conversion matrix
    println!("\n📊 Indic-to-Indic Conversion Matrix:");
    println!("{:<20} {}", "Source→Target", "Success/Total");
    println!("{}", "-".repeat(45));

    for &source in &available_indic {
        for &target in &available_indic {
            if source != target {
                if let Some((succeeded, total)) = conversion_matrix.get(&(source, target)) {
                    let percentage = if *total > 0 {
                        succeeded * 100 / total
                    } else {
                        0
                    };
                    println!(
                        "{:<20} {}/{} ({}%)",
                        format!("{}→{}", source, target),
                        succeeded,
                        total,
                        percentage
                    );
                }
            }
        }
    }

    if !failures.is_empty() {
        println!("\n❌ Indic-to-Indic conversion failures:");
        for failure in &failures[..failures.len().min(10)] {
            println!("  {}", failure);
        }
        if failures.len() > 10 {
            println!("  ... and {} more failures", failures.len() - 10);
        }
    }
}

#[test]
fn test_roman_to_indic_conversions() {
    let shlesha = Shlesha::new();
    let supported_scripts = shlesha.list_supported_scripts();

    let available_roman: Vec<&str> = ROMAN_SCRIPTS
        .iter()
        .filter(|script| supported_scripts.contains(&script.to_string()))
        .copied()
        .collect();

    let available_indic: Vec<&str> = INDIC_SCRIPTS
        .iter()
        .filter(|script| supported_scripts.contains(&script.to_string()))
        .copied()
        .collect();

    let mut conversion_matrix = HashMap::new();
    let mut failures = Vec::new();

    // Test Roman→Indic conversions
    for &roman in &available_roman {
        for &indic in &available_indic {
            let mut conversions_tested = 0;
            let mut conversions_succeeded = 0;

            // Use IAST test cases as source
            let test_cases: Vec<_> = get_test_cases()
                .into_iter()
                .filter(|tc| tc.script == "iast")
                .take(5) // Limit for performance
                .collect();

            for test_case in &test_cases {
                conversions_tested += 1;

                // Convert from IAST to Roman script (if needed)
                let roman_text = if roman == "iast" {
                    test_case.text.to_string()
                } else {
                    match shlesha.transliterate(test_case.text, "iast", roman) {
                        Ok(text) => text,
                        Err(e) => {
                            failures.push(format!(
                                "Prep failed: IAST→{}: '{}' - {}",
                                roman, test_case.text, e
                            ));
                            continue;
                        }
                    }
                };

                // Convert from Roman to Indic
                match shlesha.transliterate(&roman_text, roman, indic) {
                    Ok(result) => {
                        conversions_succeeded += 1;
                        println!("✓ {}→{}: '{}' → '{}'", roman, indic, roman_text, result);
                    }
                    Err(e) => {
                        failures.push(format!(
                            "{}→{}: '{}' failed - {}",
                            roman, indic, roman_text, e
                        ));
                    }
                }
            }

            conversion_matrix.insert((roman, indic), (conversions_succeeded, conversions_tested));
        }
    }

    // Print conversion matrix
    println!("\n📊 Roman-to-Indic Conversion Matrix:");
    println!("{:<20} {}", "Source→Target", "Success/Total");
    println!("{}", "-".repeat(45));

    for &roman in &available_roman {
        for &indic in &available_indic {
            if let Some((succeeded, total)) = conversion_matrix.get(&(roman, indic)) {
                let percentage = if *total > 0 {
                    succeeded * 100 / total
                } else {
                    0
                };
                println!(
                    "{:<20} {}/{} ({}%)",
                    format!("{}→{}", roman, indic),
                    succeeded,
                    total,
                    percentage
                );
            }
        }
    }

    if !failures.is_empty() {
        println!("\n❌ Roman-to-Indic conversion failures:");
        for failure in &failures[..failures.len().min(15)] {
            println!("  {}", failure);
        }
        if failures.len() > 15 {
            println!("  ... and {} more failures", failures.len() - 15);
        }
    }
}

#[test]
fn test_indic_to_roman_conversions() {
    let shlesha = Shlesha::new();
    let supported_scripts = shlesha.list_supported_scripts();

    let available_roman: Vec<&str> = ROMAN_SCRIPTS
        .iter()
        .filter(|script| supported_scripts.contains(&script.to_string()))
        .copied()
        .collect();

    let available_indic: Vec<&str> = INDIC_SCRIPTS
        .iter()
        .filter(|script| supported_scripts.contains(&script.to_string()))
        .copied()
        .collect();

    let mut conversion_matrix = HashMap::new();
    let mut failures = Vec::new();

    // Test Indic→Roman conversions
    for &indic in &available_indic {
        for &roman in &available_roman {
            let mut conversions_tested = 0;
            let mut conversions_succeeded = 0;

            // Use Devanagari test cases as source
            let test_cases: Vec<_> = get_test_cases()
                .into_iter()
                .filter(|tc| tc.script == "devanagari")
                .take(5) // Limit for performance
                .collect();

            for test_case in &test_cases {
                conversions_tested += 1;

                // Convert from Devanagari to Indic script (if needed)
                let indic_text = if indic == "devanagari" {
                    test_case.text.to_string()
                } else {
                    match shlesha.transliterate(test_case.text, "devanagari", indic) {
                        Ok(text) => text,
                        Err(e) => {
                            failures.push(format!(
                                "Prep failed: Devanagari→{}: '{}' - {}",
                                indic, test_case.text, e
                            ));
                            continue;
                        }
                    }
                };

                // Convert from Indic to Roman
                match shlesha.transliterate(&indic_text, indic, roman) {
                    Ok(result) => {
                        conversions_succeeded += 1;
                        println!("✓ {}→{}: '{}' → '{}'", indic, roman, indic_text, result);
                    }
                    Err(e) => {
                        failures.push(format!(
                            "{}→{}: '{}' failed - {}",
                            indic, roman, indic_text, e
                        ));
                    }
                }
            }

            conversion_matrix.insert((indic, roman), (conversions_succeeded, conversions_tested));
        }
    }

    // Print conversion matrix
    println!("\n📊 Indic-to-Roman Conversion Matrix:");
    println!("{:<20} {}", "Source→Target", "Success/Total");
    println!("{}", "-".repeat(45));

    for &indic in &available_indic {
        for &roman in &available_roman {
            if let Some((succeeded, total)) = conversion_matrix.get(&(indic, roman)) {
                let percentage = if *total > 0 {
                    succeeded * 100 / total
                } else {
                    0
                };
                println!(
                    "{:<20} {}/{} ({}%)",
                    format!("{}→{}", indic, roman),
                    succeeded,
                    total,
                    percentage
                );
            }
        }
    }

    if !failures.is_empty() {
        println!("\n❌ Indic-to-Roman conversion failures:");
        for failure in &failures[..failures.len().min(15)] {
            println!("  {}", failure);
        }
        if failures.len() > 15 {
            println!("  ... and {} more failures", failures.len() - 15);
        }
    }
}

#[test]
fn test_round_trip_consistency() {
    let shlesha = Shlesha::new();
    let supported_scripts = shlesha.list_supported_scripts();

    let available_roman: Vec<&str> = ROMAN_SCRIPTS
        .iter()
        .filter(|script| supported_scripts.contains(&script.to_string()))
        .copied()
        .collect();

    let mut round_trip_failures = Vec::new();
    let mut round_trip_successes = 0;
    let mut round_trips_tested = 0;

    // Test round-trip conversions within Roman scripts
    for &script1 in &available_roman {
        for &script2 in &available_roman {
            if script1 == script2 {
                continue;
            }

            let test_cases: Vec<_> = get_test_cases()
                .into_iter()
                .filter(|tc| tc.script == script1)
                .take(3)
                .collect();

            for test_case in &test_cases {
                round_trips_tested += 1;

                // script1 → script2 → script1
                match shlesha
                    .transliterate(test_case.text, script1, script2)
                    .and_then(|intermediate| shlesha.transliterate(&intermediate, script2, script1))
                {
                    Ok(final_result) => {
                        if final_result == test_case.text {
                            round_trip_successes += 1;
                            println!(
                                "✓ Round-trip {}→{}→{}: '{}'",
                                script1, script2, script1, test_case.text
                            );
                        } else {
                            round_trip_failures.push(format!(
                                "Round-trip {}→{}→{}: '{}' → '{}'",
                                script1, script2, script1, test_case.text, final_result
                            ));
                        }
                    }
                    Err(e) => {
                        round_trip_failures.push(format!(
                            "Round-trip {}→{}→{}: '{}' failed - {}",
                            script1, script2, script1, test_case.text, e
                        ));
                    }
                }
            }
        }
    }

    println!("\n🔄 Round-trip Results:");
    println!(
        "Successful round-trips: {}/{} ({}%)",
        round_trip_successes,
        round_trips_tested,
        if round_trips_tested > 0 {
            round_trip_successes * 100 / round_trips_tested
        } else {
            0
        }
    );

    if !round_trip_failures.is_empty() {
        println!("\n❌ Round-trip failures:");
        for failure in &round_trip_failures[..round_trip_failures.len().min(10)] {
            println!("  {}", failure);
        }
        if round_trip_failures.len() > 10 {
            println!("  ... and {} more failures", round_trip_failures.len() - 10);
        }
    }
}

#[test]
fn test_comprehensive_coverage_report() {
    let shlesha = Shlesha::new();
    let supported_scripts = shlesha.list_supported_scripts();

    println!("\n📋 COMPREHENSIVE COVERAGE REPORT");
    println!("================================");

    println!("\n🎯 Target Coverage:");
    println!("Scripts in schemas: {}", ALL_SCRIPTS.len());
    println!("Scripts supported: {}", supported_scripts.len());
    println!("Roman scripts: {}", ROMAN_SCRIPTS.len());
    println!("Indic scripts: {}", INDIC_SCRIPTS.len());

    let total_possible_conversions = supported_scripts.len() * (supported_scripts.len() - 1);
    println!("Total possible conversions: {}", total_possible_conversions);

    println!("\n📊 Test Coverage Matrix:");
    println!(
        "✓ Identity conversions: {} scripts",
        supported_scripts.len()
    );
    println!("✓ Roman→Roman: tested in test_roman_to_roman_conversions");
    println!("✓ Indic→Indic: tested in test_indic_to_indic_conversions");
    println!("✓ Roman→Indic: tested in test_roman_to_indic_conversions");
    println!("✓ Indic→Roman: tested in test_indic_to_roman_conversions");
    println!("✓ Round-trips: tested in test_round_trip_consistency");

    println!("\n🔍 Known Issues:");
    println!("❌ IAST→SLP1 conversion broken (outputs unchanged text)");
    println!("❌ SLP1→IAST conversion outputs ISO-15919 instead");
    println!("❌ Hub conversion system has reverse mapping issues");

    println!("\n💡 Recommendations:");
    println!("1. Fix reverse mapping generation in build.rs");
    println!("2. Add property-based testing for all script pairs");
    println!("3. Add character-level mapping verification");
    println!("4. Add performance regression tests");
    println!("5. Add CI test that runs full matrix on every commit");
}