#!/usr/bin/env python3
"""
Test the complete pipeline to identify where the long vowel conversion fails
"""


def test_complete_pipeline():
    """Test the complete conversion pipeline"""
    import sys

    sys.path.append("/home/ouaillaamiri/Development/Oit LAB/CaDaR")
    import cadar

    print("Testing complete pipeline for long vowels...")
    print("=" * 60)

    # Test the most basic case: "aa"
    test_word = "aa"
    print(f"\nTesting: '{test_word}'")

    # Step 1: Latin to Arabic
    arabic_result = cadar.bizi2ara(test_word)
    print(f"Step 1 - Latin → Arabic: '{test_word}' → '{arabic_result}'")

    # Expected: should be "اا" (double alef)
    if arabic_result == "اا":
        print("  ✅ Latin to Arabic: CORRECT - generated double alef")
    elif arabic_result == "ا":
        print("  ❌ Latin to Arabic: WRONG - generated single alef instead of double")
    else:
        print(f"  ❌ Latin to Arabic: UNEXPECTED - got '{arabic_result}'")

    # Step 2: Arabic back to Latin
    if arabic_result:
        latin_result = cadar.ara2bizi(arabic_result)
        print(f"Step 2 - Arabic → Latin: '{arabic_result}' → '{latin_result}'")

        if latin_result == test_word:
            print("  ✅ Arabic to Latin: CORRECT - perfect roundtrip")
        else:
            print(
                f"  ❌ Arabic to Latin: WRONG - expected '{test_word}', got '{latin_result}'"
            )

    # Test manually created double Arabic
    print(f"\nTesting manually created double Arabic...")
    manual_double = "اا"
    manual_latin = cadar.ara2bizi(manual_double)
    print(f"Manual test: '{manual_double}' → '{manual_latin}'")

    if manual_latin == "aa":
        print("  ✅ Manual double Arabic: CORRECT")
    else:
        print(f"  ❌ Manual double Arabic: WRONG - expected 'aa', got '{manual_latin}'")


if __name__ == "__main__":
    test_complete_pipeline()
