Skip to content

Commit 4791f43

Browse files
committed
Move test to inequality.rs. Add the same test for less_than.
1 parent 31ee9e4 commit 4791f43

File tree

2 files changed

+35
-15
lines changed

2 files changed

+35
-15
lines changed

pumpkin-crates/core/src/constraints/arithmetic/inequality.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,38 @@ impl<Var: IntegerVariable + 'static> NegatableConstraint for Inequality<Var> {
140140
}
141141
}
142142
}
143+
144+
#[cfg(test)]
145+
mod tests {
146+
use super::*;
147+
148+
#[test]
149+
fn less_than_conflict() {
150+
let mut solver = Solver::default();
151+
152+
let constraint_tag = solver.new_constraint_tag();
153+
let x = solver.new_named_bounded_integer(0, 0, "x");
154+
155+
let result = less_than([x], 0, constraint_tag).post(&mut solver);
156+
assert_eq!(
157+
result,
158+
Err(ConstraintOperationError::InfeasiblePropagator),
159+
"Expected {result:?} to be an `InfeasiblePropagator` error"
160+
);
161+
}
162+
163+
#[test]
164+
fn greater_than_conflict() {
165+
let mut solver = Solver::default();
166+
167+
let constraint_tag = solver.new_constraint_tag();
168+
let x = solver.new_named_bounded_integer(0, 0, "x");
169+
170+
let result = greater_than([x], 0, constraint_tag).post(&mut solver);
171+
assert_eq!(
172+
result,
173+
Err(ConstraintOperationError::InfeasiblePropagator),
174+
"Expected {result:?} to be an `InfeasiblePropagator` error"
175+
);
176+
}
177+
}

pumpkin-solver/tests/solver_test.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,3 @@ fn proof_with_equality_unit_nogood_step() {
6464
let result = solver.satisfy(&mut brancher, &mut Indefinite);
6565
assert!(matches!(result, SatisfactionResult::Unsatisfiable(_, _)));
6666
}
67-
68-
#[test]
69-
fn greater_than_bug() {
70-
let mut solver = Solver::default();
71-
72-
let constraint_tag = solver.new_constraint_tag();
73-
let x = solver.new_named_bounded_integer(0, 0, "x");
74-
let gt = solver.add_constraint(constraints::greater_than([x], 0, constraint_tag));
75-
76-
match gt.post() {
77-
Err(ConstraintOperationError::InfeasiblePropagator) => {}
78-
Ok(()) => panic!("expected InfeasiblePropagator when posting x > 0 for x fixed to 0"),
79-
Err(e) => panic!("unexpected error: {e:?}"),
80-
}
81-
}

0 commit comments

Comments
 (0)