31 lines
835 B
Python
31 lines
835 B
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():
|
|
n = Normalizer()
|
|
assert n.normalize_encoding(b'\xc1\xc2', "EBCDIC") == "AB"
|
|
|
|
|
|
def test_ascii_passthrough():
|
|
assert Normalizer().normalize_encoding(b"hello", "ASCII") == "hello"
|
|
|
|
|
|
def test_comp3():
|
|
assert Normalizer().normalize_comp3(b'\x00\x15\x0C') == "150"
|
|
|
|
def test_comp3_negative():
|
|
assert Normalizer().normalize_comp3(b'\x15\x0D') == "-150"
|
|
|
|
|
|
def test_date_iso():
|
|
assert Normalizer().normalize_date("20260522") == "2026-05-22"
|
|
|
|
|
|
def test_ir_record():
|
|
n = Normalizer()
|
|
ir = n.to_ir_record("BR-AMT", "15000C", "1500", "EBCDIC", "COMP3", 5, 2, True)
|
|
assert ir.field_name == "BR-AMT"
|
|
assert ir.cobol.decoded_value == "1500"
|