test: add edge case tests

This commit is contained in:
hangshuo652
2026-05-24 13:01:31 +08:00
parent 331b38eac1
commit faeedbc77b
2 changed files with 33 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
import sys, os
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")))
from comparator.aligner import align_records
def test_align_large_key_set():
cobol = [{"ID": f"K{i:04d}", "V": i} for i in range(100)]
spark = [{"ID": f"K{i:04d}", "V": i} for i in range(100)]
result = align_records(cobol, spark, key_field="ID")
assert len(result) == 100
assert all(st == "MATCHED" for _, _, st in result)
def test_align_empty_key_value():
cobol = [{"ID": "", "V": 1}]
spark = [{"ID": "", "V": 1}]
result = align_records(cobol, spark, key_field="ID")
assert len(result) == 1
+15
View File
@@ -0,0 +1,15 @@
import sys, os
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")))
from comparator.field_compare import compare_field, DEFAULT_TOLERANCE
def test_negative_numbers():
assert compare_field("AMT", "-1500", "-1500", "decimal").status == "PASS"
def test_mixed_precision():
assert compare_field("AMT", "1500.00", "1500", "decimal", DEFAULT_TOLERANCE).status == "PASS"
def test_very_large_number():
assert compare_field("AMT", "9999999999", "9999999999", "decimal").status == "PASS"