48 lines
1.3 KiB
Python
48 lines
1.3 KiB
Python
import sys, os
|
|
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")))
|
|
from comparator.normalizer import Normalizer
|
|
|
|
|
|
def test_ebcdic_to_ascii():
|
|
n = Normalizer()
|
|
assert n.normalize_encoding(b'\xc1\xc2', "EBCDIC") == "AB"
|
|
|
|
|
|
def test_ascii_passthrough():
|
|
n = Normalizer()
|
|
assert n.normalize_encoding(b"hello", "ASCII") == "hello"
|
|
|
|
|
|
def test_comp3_to_decimal():
|
|
n = Normalizer()
|
|
assert n.normalize_comp3(b'\x15\x00\x0C') == "1500"
|
|
|
|
|
|
def test_comp3_negative():
|
|
n = Normalizer()
|
|
assert n.normalize_comp3(b'\x15\x00\x1D') == "-1500"
|
|
|
|
|
|
def test_ir_record_creation():
|
|
n = Normalizer()
|
|
ir = n.to_ir_record(
|
|
field_name="BR-AMT", raw_hex="15000C",
|
|
decoded_value="1500", encoding="EBCDIC",
|
|
field_type="COMP3", length=5, scale=2, signed=True)
|
|
assert ir.field_name == "BR-AMT"
|
|
assert ir.cobol.decoded_value == "1500"
|
|
assert ir.cobol.encoding == "EBCDIC"
|
|
|
|
|
|
def test_date_iso_normalization():
|
|
n = Normalizer()
|
|
assert n.normalize_date("20260522") == "2026-05-22"
|
|
assert n.normalize_date("2026-05-22") == "2026-05-22"
|
|
|
|
|
|
def test_null_ir_record():
|
|
n = Normalizer()
|
|
ir = n.to_null_ir("BR-DATE", side="java")
|
|
assert ir.field_name == "BR-DATE"
|
|
assert ir.java is None
|