//! Invalid input returns an empty list when strict mode is off.

mod common;

use common::exact;
use expand_range::{expand, Options, Step, Value};

/// expand(start, end) with no step.
fn f2(start: &str, end: &str) -> expand_range::FillResult {
    expand(
        Value::from(start),
        Some(Value::from(end)),
        Step::None,
        Options::new(),
    )
}

/// expand(start, end, step).
fn f3(start: &str, end: &str, step: &str) -> expand_range::FillResult {
    expand(
        Value::from(start),
        Some(Value::from(end)),
        Step::from(step),
        Options::new(),
    )
}

#[test]
fn invalid_returns_empty() {
    exact(f2("1", "0f"), &[]);
    exact(f3("1", "10", "ff"), &[]);
    exact(f2("1", "10.f"), &[]);
    exact(f2("1", "10f"), &[]);
    exact(f3("1", "20", "2f"), &[]);
    exact(f3("1", "20", "f2"), &[]);
    exact(f2("1", "2f"), &[]);
    exact(f3("1", "2f", "2"), &[]);
    exact(f2("1", "f2"), &[]);
    exact(f2("1", "ff"), &[]);
    exact(f3("1", "ff", "2"), &[]);
    exact(f2("1.1", "2.1"), &[]);
    exact(f2("1.2", "2"), &[]);
    exact(f2("1.20", "2"), &[]);
}

#[test]
fn radix_prefixed_bounds_are_not_numbers() {
    // Hex, octal, and binary literals are out of scope for numeric coercion.
    // They fail the integer check and produce an empty range.
    exact(f2("1", "0x10"), &[]);
    exact(f2("1", "0o10"), &[]);
    exact(f2("1", "0b10"), &[]);
    exact(f3("1", "10", "0x2"), &[]);
}
