25 lines
656 B
Python
25 lines
656 B
Python
import sys, os
|
|
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")))
|
|
from comparator.rounding_detect import detect_rounding, RoundingResult
|
|
|
|
|
|
def test_truncation_detected():
|
|
r = detect_rounding("1500000", "1499999")
|
|
assert r.mode in ("TRUNCATE", "HALF_UP")
|
|
|
|
|
|
def test_exact_match():
|
|
r = detect_rounding("1500000", "1500000")
|
|
assert r.mode == "EXACT"
|
|
assert r.confidence == 1.0
|
|
|
|
|
|
def test_low_confidence_small_diff():
|
|
r = detect_rounding("1500", "1498")
|
|
assert r.confidence < 1.0
|
|
|
|
|
|
def test_suggestion_generated():
|
|
r = detect_rounding("1500000", "1499999")
|
|
assert len(r.suggestion) > 0
|