1
// Tests for various functionalities of the Model
2

            
3
use std::collections::HashMap;
4

            
5
use conjure_core::metadata::Metadata;
6
use conjure_core::model::Model;
7
use conjure_oxide::ast::*;
8

            
9
#[test]
10
1
fn modify_domain() {
11
1
    let a = Name::UserName(String::from("a"));
12
1

            
13
1
    let d1 = Domain::IntDomain(vec![Range::Bounded(1, 3)]);
14
1
    let d2 = Domain::IntDomain(vec![Range::Bounded(1, 2)]);
15
1

            
16
1
    let mut variables = HashMap::new();
17
1
    variables.insert(a.clone(), DecisionVariable { domain: d1.clone() });
18
1

            
19
1
    let mut m = Model::new(
20
1
        variables,
21
1
        Expression::And(Metadata::new(), Vec::new()),
22
1
        Default::default(),
23
1
    );
24
1

            
25
1
    assert_eq!(m.variables.get(&a).unwrap().domain, d1);
26

            
27
1
    m.update_domain(&a, d2.clone());
28
1

            
29
1
    assert_eq!(m.variables.get(&a).unwrap().domain, d2);
30
1
}