use automapper_validation::eval::{
ConditionEvaluator, ConditionResult, EvaluationContext, NoOpExternalProvider,
};
use automapper_validation::ReqoteConditionEvaluatorFV2510;
use mig_types::segment::OwnedSegment;
fn eval(value: Option<&str>) -> ConditionResult {
let evaluator = ReqoteConditionEvaluatorFV2510::default();
let ext = NoOpExternalProvider;
let segs: Vec<OwnedSegment> = vec![];
let base = EvaluationContext::new("15002", &ext, &segs);
let ctx = base.with_resolved(value, None);
evaluator.evaluate(911, &ctx)
}
#[test]
fn reqote_911_true_for_1() {
assert_eq!(eval(Some("1")), ConditionResult::True);
}
#[test]
fn reqote_911_true_for_multi_digit() {
assert_eq!(eval(Some("42")), ConditionResult::True);
assert_eq!(eval(Some("12345")), ConditionResult::True);
}
#[test]
fn reqote_911_false_for_zero() {
assert_eq!(eval(Some("0")), ConditionResult::False);
}
#[test]
fn reqote_911_false_for_leading_zeros() {
assert_eq!(eval(Some("01")), ConditionResult::False);
assert_eq!(eval(Some("001")), ConditionResult::False);
}
#[test]
fn reqote_911_false_for_negative_or_decimal() {
assert_eq!(eval(Some("-1")), ConditionResult::False);
assert_eq!(eval(Some("1.5")), ConditionResult::False);
}
#[test]
fn reqote_911_false_for_non_digit() {
assert_eq!(eval(Some("abc")), ConditionResult::False);
assert_eq!(eval(Some("1x")), ConditionResult::False);
}
#[test]
fn reqote_911_unknown_for_missing_value() {
assert_eq!(eval(None), ConditionResult::Unknown);
assert_eq!(eval(Some("")), ConditionResult::Unknown);
}