#!/usr/bin/env python3
"""
Test script to verify long vowel roundtrip conversion
"""

import cadar


def test_long_vowel_roundtrip():
    """Test that long vowels work correctly in both directions"""

    # Test cases for long vowels
    test_cases = [
        # Latin to Arabic to Latin
        ("laa", "aa"),
        ("sii", "ii"),
        ("ruu", "uu"),
        ("moo", "oo"),
        # Words with long vowels
        ("saal", "aal"),
        ("shiir", "iir"),
        ("yuum", "uum"),
        ("noom", "oom"),
    ]

    print("Testing long vowel roundtrip conversion...")
    print("=" * 50)

    for latin_word, long_vowel in test_cases:
        print(f"\nTesting: {latin_word}")

        # Latin to Arabic
        arabic_result = cadar.bizi2ara(latin_word)
        print(f"  Latin → Arabic: {latin_word} → {arabic_result}")

        # Arabic back to Latin
        back_to_latin = cadar.ara2bizi(arabic_result)
        print(f"  Arabic → Latin: {arabic_result} → {back_to_latin}")

        # Check if roundtrip worked
        if back_to_latin == latin_word:
            print(f"  ✅ SUCCESS: Perfect roundtrip!")
        elif long_vowel in back_to_latin:
            print(f"  ⚠️  PARTIAL: Long vowel preserved but not exact match")
            print(f"     Expected: {latin_word}")
            print(f"     Got:      {back_to_latin}")
        else:
            print(f"  ❌ FAILED: Long vowel lost in roundtrip")
            print(f"     Expected: {latin_word}")
            print(f"     Got:      {back_to_latin}")


if __name__ == "__main__":
    test_long_vowel_roundtrip()
