Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions test_min_cost_string_conversion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import pytest

Check failure on line 1 in test_min_cost_string_conversion.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (F401)

test_min_cost_string_conversion.py:1:8: F401 `pytest` imported but unused help: Remove unused import: `pytest`

Check failure on line 1 in test_min_cost_string_conversion.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (F401)

test_min_cost_string_conversion.py:1:8: F401 `pytest` imported but unused help: Remove unused import: `pytest`
from strings.min_cost_string_conversion import (
compute_transform_tables,
assemble_transformation,
)

Check failure on line 5 in test_min_cost_string_conversion.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (I001)

test_min_cost_string_conversion.py:1:1: I001 Import block is un-sorted or un-formatted help: Organize imports

Check failure on line 5 in test_min_cost_string_conversion.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (I001)

test_min_cost_string_conversion.py:1:1: I001 Import block is un-sorted or un-formatted help: Organize imports


def test_empty_strings():
costs, ops = compute_transform_tables("", "", 1, 1, 1, 1)
assert costs == [[0]]
assert assemble_transformation(ops, 0, 0) == []


def test_copy_only():
costs, ops = compute_transform_tables("abc", "abc", 1, 2, 3, 3)
assert costs[-1][-1] == 3 # cost = sum of copy costs
assert assemble_transformation(ops, len(ops) - 1, len(ops[0]) - 1) == [
"Ca",
"Cb",
"Cc",
]


def test_insert_only():
costs, ops = compute_transform_tables("", "xyz", 1, 1, 1, 1)

Check failure on line 25 in test_min_cost_string_conversion.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (RUF059)

test_min_cost_string_conversion.py:25:5: RUF059 Unpacked variable `costs` is never used help: Prefix it with an underscore or any other dummy variable pattern

Check failure on line 25 in test_min_cost_string_conversion.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (RUF059)

test_min_cost_string_conversion.py:25:5: RUF059 Unpacked variable `costs` is never used help: Prefix it with an underscore or any other dummy variable pattern
seq = assemble_transformation(ops, 0, len(ops[0]) - 1)
assert seq == ["Ix", "Iy", "Iz"]
Loading