|
| 1 | +import pytest |
| 2 | + |
| 3 | +from leetcode_py import logged_test |
| 4 | + |
| 5 | +from .helpers import assert_alien_order, run_alien_order |
| 6 | +from .solution import Solution |
| 7 | + |
| 8 | + |
| 9 | +class TestAlienDictionary: |
| 10 | + def setup_method(self): |
| 11 | + self.solution = Solution() |
| 12 | + |
| 13 | + @logged_test |
| 14 | + @pytest.mark.parametrize( |
| 15 | + "words, expected", |
| 16 | + [ |
| 17 | + (["wrt", "wrf", "er", "ett", "rftt"], "wertf"), |
| 18 | + (["z", "x"], "zx"), |
| 19 | + (["z", "x", "z"], ""), |
| 20 | + (["z", "z"], "z"), |
| 21 | + (["abc", "ab"], ""), |
| 22 | + (["ab", "adc"], "abdc"), |
| 23 | + (["ac", "ab", "zc", "zb"], "acbz"), |
| 24 | + (["z"], "z"), |
| 25 | + (["za", "zb", "ca", "cb"], "zcab"), |
| 26 | + (["zy", "zx"], "zyx"), |
| 27 | + (["a", "b", "ca", "cc"], "abc"), |
| 28 | + (["abc", "bcd", "cde"], "abcde"), |
| 29 | + (["a", "aa"], "a"), |
| 30 | + (["ab", "abc"], "abc"), |
| 31 | + (["abc", "ab"], ""), |
| 32 | + (["a", "b", "c", "d"], "abcd"), |
| 33 | + (["d", "c", "b", "a"], "dcba"), |
| 34 | + (["ac", "ab", "b"], "acb"), |
| 35 | + ], |
| 36 | + ) |
| 37 | + def test_alien_order(self, words: list[str], expected: str): |
| 38 | + result = run_alien_order(Solution, words) |
| 39 | + assert_alien_order(result, expected) |
0 commit comments