#!/usr/bin/env python3
"""
Direct test of the ICR and script generation logic
"""

import cadar


def test_arabic_double_chars():
    """Test if Arabic double characters are properly converted back"""

    print("Testing Arabic double character conversion...")
    print("=" * 50)

    # Test if double alef (اا) converts back to aa
    test_cases = [
        "اا",  # double alef (should become aa)
        "يي",  # double yeh (should become ii)
        "وو",  # double waw (should become uu/oo)
        "لاا",  # lam + double alef (should become laa)
        "سيي",  # sin + double yeh (should become sii)
    ]

    for arabic_text in test_cases:
        latin_result = cadar.ara2bizi(arabic_text)
        print(f"'{arabic_text}' → '{latin_result}'")


def test_latin_to_arabic_generation():
    """Test if Latin long vowels generate double Arabic characters"""

    print("\nTesting Latin long vowel to Arabic generation...")
    print("=" * 50)

    test_cases = [
        "aa",  # should become اا
        "ii",  # should become يي
        "uu",  # should become وو
        "oo",  # should become وو
        "laa",  # should become ل + اا
        "sii",  # should become س + يي
    ]

    for latin_text in test_cases:
        arabic_result = cadar.bizi2ara(latin_text)
        print(f"'{latin_text}' → '{arabic_result}'")
        # Check if we have double characters
        has_double = (
            "اا" in arabic_result or "يي" in arabic_result or "وو" in arabic_result
        )
        print(f"  Has double chars: {has_double}")


if __name__ == "__main__":
    test_arabic_double_chars()
    test_latin_to_arabic_generation()
