Files
cobol-java/tests/comparator/test_field_compare.py
T

50 lines
1.4 KiB
Python

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_exact_match():
r = compare_field("BR-AMT", "1500000", "1500000", "decimal")
assert r.status == "PASS"
def test_within_tolerance():
r = compare_field("BR-AMT", "1500000", "1499999.99", "decimal", tolerance=DEFAULT_TOLERANCE)
assert r.status == "TOLERATED"
def test_beyond_tolerance():
r = compare_field("BR-AMT", "1500000", "1000000", "decimal", tolerance=DEFAULT_TOLERANCE)
assert r.status == "MISMATCH"
def test_string_trim():
r = compare_field("BR-STATUS", "A ", "A", "string")
assert r.status == "PASS"
def test_date_normalization():
r = compare_field("BR-DATE", "20260522", "2026-05-22", "date")
assert r.status == "PASS"
def test_cobol_default():
from decimal import Decimal, ROUND_DOWN
r = compare_field("BR-AMT", "\x00\x00\x00\x00\x00", "0", "decimal")
assert r.status in ("PASS", "TOLERATED")
def test_java_null_vs_value():
r = compare_field("BR-AMT", "1500000", "None", "decimal")
assert r.status in ("MISMATCH", "NOT_SET")
def test_negative_numbers():
r = compare_field("AMT", "-1500", "-1500", "decimal")
assert r.status == "PASS"
def test_mixed_precision():
r = compare_field("AMT", "1500.00", "1500", "decimal", tolerance=DEFAULT_TOLERANCE)
assert r.status == "PASS"