Skip to content

Commit c8b8909

Browse files
authored
Implement tests for string transformation functions
Add unit tests for min cost string conversion functions.
1 parent 678dedb commit c8b8909

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test_min_cost_string_conversion.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import pytest
2+
from strings.min_cost_string_conversion import compute_transform_tables, assemble_transformation
3+
4+
def test_empty_strings():
5+
costs, ops = compute_transform_tables("", "", 1,1,1,1)
6+
assert costs == [[0]]
7+
assert assemble_transformation(ops, 0, 0) == []
8+
9+
def test_copy_only():
10+
costs, ops = compute_transform_tables("abc", "abc", 1,2,3,3)
11+
assert costs[-1][-1] == 3 # cost = sum of copy costs
12+
assert assemble_transformation(ops, len(ops)-1, len(ops[0])-1) == ["Ca", "Cb", "Cc"]
13+
14+
def test_insert_only():
15+
costs, ops = compute_transform_tables("", "xyz", 1,1,1,1)
16+
seq = assemble_transformation(ops, 0, len(ops[0])-1)
17+
assert seq == ["Ix", "Iy", "Iz"]

0 commit comments

Comments
 (0)