1
//! based on this minion test file:
2
//! https://github.com/minion/minion/blob/main/test_instances/test_watchedor_reifyimply_1.minion
3
//!
4
//! ```text
5
//! #TEST SOLCOUNT 7
6
//! # Recursive test
7
//! MINION 3
8
//!
9
//! **VARIABLES**
10
//! BOOL a
11
//! BOOL b
12
//! BOOL c
13
//!
14
//! **CONSTRAINTS**
15
//!
16
//! reifyimply(watched-or({w-inset(a,[1]),w-inset(b,[0])}), c)
17
//!
18
//! **EOF**
19
//! ```
20

            
21
use minion_sys::ast::{Constant, Constraint, Model, Var, VarDomain};
22
use minion_sys::error::MinionError;
23
#[test]
24
#[allow(clippy::panic_in_result_fn)]
25
1
fn test_watchedor_reifyimply_1() -> Result<(), MinionError> {
26
1
    let mut model = Model::new();
27
1
    model
28
1
        .named_variables
29
1
        .add_var(String::from("a"), VarDomain::Bool);
30
1
    model
31
1
        .named_variables
32
1
        .add_var(String::from("b"), VarDomain::Bool);
33
1
    model
34
1
        .named_variables
35
1
        .add_var(String::from("c"), VarDomain::Bool);
36

            
37
1
    model.constraints.push(Constraint::ReifyImply(
38
1
        Box::new(Constraint::WatchedOr(vec![
39
1
            Constraint::WInset(Var::NameRef(String::from("a")), vec![Constant::Bool(true)]),
40
1
            Constraint::WInset(Var::NameRef(String::from("b")), vec![Constant::Bool(false)]),
41
1
        ])),
42
1
        Var::NameRef(String::from("c")),
43
1
    ));
44

            
45
1
    let mut sols_counter = 0i32;
46
1
    let solver_ctx = minion_sys::run_minion(
47
1
        model,
48
7
        Box::new(|_| {
49
7
            sols_counter += 1;
50
7
            true
51
7
        }),
52
    )?;
53

            
54
1
    assert_eq!(sols_counter, 7);
55
1
    assert_ne!(solver_ctx.get_from_table("Nodes".into()), None);
56
1
    Ok(())
57
1
}