# Path: pypinyin/pinyin_dict.py

# 
# Path: pypinyin/contrib/tone_convert.py



from pytest import mark
from pypinyin import pinyin_dict
from pypinyin.contrib.tone_convert import (
    tone_to_normal,
    tone_to_tone2,
    tone2_to_tone,
    tone_to_tone3,
    tone3_to_tone,
    tone2_to_normal,
    tone2_to_tone3,
    tone3_to_tone2,
    tone3_to_normal,
    to_normal,
    to_tone,
    to_tone2,
    to_tone3,
    to_initials,
    to_finals,
    to_finals_tone,
    to_finals_tone2,
    to_finals_tone3,
)
    ['yu1', True, False, False, 'v1'],
    ['yū', True, True, False, 'ü1'],
    ['yū', False, False, False, 'u1'],
    ['yū', False, True, False, 'u1'],
])
def test_to_finals_tone3(pinyin, strict, v_to_u, neutral_tone_with_five,
                         result):
    assert to_finals_tone3(pinyin, strict=strict, v_to_u=v_to_u,
                           neutral_tone_with_five=neutral_tone_with_five
                           ) == result


# 所有拼音转换为 tone2 或 tone3 风格后，都可以再转换回原始的拼音
def test_tone_to_tone2_tone3_to_tone():
    pinyin_set = set()
    for py in pinyin_dict.pinyin_dict.values():
        pinyin_set.update(py.split(','))

    for py in pinyin_set:
        tone2 = tone_to_tone2(py)
        assert tone2_to_tone(tone2) == py
        assert to_tone(tone2) == py

        tone2_3 = tone2_to_tone3(tone2)
        assert tone3_to_tone(tone2_3) == py
        assert to_tone(tone2_3) == py

        #
        tone3 = tone_to_tone3(py)
        assert tone3_to_tone(tone3) == py

# Path: pypinyin/pinyin_dict.py

# 
# Path: pypinyin/contrib/tone_convert.py



# Path: tests/contrib/test_tone_convert.py
from pytest import mark
from pypinyin import pinyin_dict
from pypinyin.contrib.tone_convert import (
    tone_to_normal,
    tone_to_tone2,
    tone2_to_tone,
    tone_to_tone3,
    tone3_to_tone,
    tone2_to_normal,
    tone2_to_tone3,
    tone3_to_tone2,
    tone3_to_normal,
    to_normal,
    to_tone,
    to_tone2,
    to_tone3,
    to_initials,
    to_finals,
    to_finals_tone,
    to_finals_tone2,
    to_finals_tone3,
)

    ['yu1', True, False, False, 'v1'],
    ['yū', True, True, False, 'ü1'],
    ['yū', False, False, False, 'u1'],
    ['yū', False, True, False, 'u1'],
])
def test_to_finals_tone3(pinyin, strict, v_to_u, neutral_tone_with_five,
                         result):
    assert to_finals_tone3(pinyin, strict=strict, v_to_u=v_to_u,
                           neutral_tone_with_five=neutral_tone_with_five
                           ) == result


# 所有拼音转换为 tone2 或 tone3 风格后，都可以再转换回原始的拼音
def test_tone_to_tone2_tone3_to_tone():
    pinyin_set = set()
    for py in pinyin_dict.pinyin_dict.values():
        pinyin_set.update(py.split(','))

    for py in pinyin_set:
        tone2 = tone_to_tone2(py)
        assert tone2_to_tone(tone2) == py
        assert to_tone(tone2) == py

        tone2_3 = tone2_to_tone3(tone2)
        assert tone3_to_tone(tone2_3) == py
        assert to_tone(tone2_3) == py

        #
        tone3 = tone_to_tone3(py)
        assert tone3_to_tone(tone3) == py

        assert to_tone(tone3) == py