Skip to content

Commit 7fd8812

Browse files
Enhance unit tests: add test2 for greater-than constraints and retract functionality; rename existing tests for clarity.
1 parent c5c13b0 commit 7fd8812

1 file changed

Lines changed: 25 additions & 2 deletions

File tree

tests/test_linspire.cpp

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,28 @@ void test1()
6868
assert(!cons);
6969
}
7070

71+
void test2()
72+
{
73+
linspire::solver s;
74+
auto x = s.new_var();
75+
76+
auto c0 = std::make_shared<linspire::constraint>();
77+
78+
// x >= 0
79+
bool res0 = s.new_gt({{x, 1}}, 0, false, c0);
80+
assert(res0);
81+
// x >= 1
82+
bool res1 = s.new_gt({{x, 1}}, 1, false, c0);
83+
assert(res1);
84+
85+
auto cons = s.check();
86+
assert(cons);
87+
88+
s.retract(c0);
89+
assert(s.lb(x) == utils::rational::negative_infinite);
90+
assert(s.ub(x) == utils::rational::positive_infinite);
91+
}
92+
7193
/**
7294
* @brief Unit test for the linspire::solver class.
7395
*
@@ -78,7 +100,7 @@ void test1()
78100
*
79101
* Assertions are used to ensure that each step behaves as expected.
80102
*/
81-
void test2()
103+
void test3()
82104
{
83105
linspire::solver s;
84106
auto x = s.new_var();
@@ -118,7 +140,7 @@ void test2()
118140
*
119141
* Assertions are used to ensure that each step behaves as expected.
120142
*/
121-
void test3()
143+
void test4()
122144
{
123145
linspire::solver s;
124146
auto x = s.new_var();
@@ -157,6 +179,7 @@ int main()
157179
test1();
158180
test2();
159181
test3();
182+
test4();
160183

161184
return 0;
162185
}

0 commit comments

Comments
 (0)