Commit 7474d29c authored by Chuanren Wu's avatar Chuanren Wu

add test

parent dc3c9377
......@@ -161,3 +161,75 @@ TEST(BC, TwoSegments1)
EXPECT_EQ(v[5], v[7]);
EXPECT_EQ(v[2], v[4]);
}
TEST(BC, ThreeSegment1)
{
std::vector<Constraint> cs;
{
Constraint c;
c.plus(0);
c.minus(2);
cs.push_back(c);
}
{
Constraint c;
c.plus(1);
c.minus(3);
cs.push_back(c);
}
{
Constraint c;
c.plus(5);
c.minus(7);
cs.push_back(c);
}
{
Constraint c;
c.plus(4);
c.minus(6);
cs.push_back(c);
}
{
Constraint c;
c.plus(8);
c.minus(10);
cs.push_back(c);
}
{
Constraint c;
c.plus(9);
c.minus(11);
cs.push_back(c);
}
{
Constraint c;
c.plus(4);
c.plus(8);
c.minus(2);
cs.push_back(c);
}
{
Constraint c;
c.plus(7);
c.minus(11);
cs.push_back(c);
}
std::vector<double> vl(12);
std::generate(vl.begin(), vl.end(), [](){ return 100.0;} );
auto v = discretizeImpl(vl, cs);
EXPECT_NE(0, v.size());
for (int i = 0; i < 12; ++i) {
EXPECT_LE(10, v[i]);
}
EXPECT_EQ(v[0], v[2]);
EXPECT_EQ(v[1], v[3]);
EXPECT_EQ(v[4], v[6]);
EXPECT_EQ(v[5], v[7]);
EXPECT_EQ(v[8], v[10]);
EXPECT_EQ(v[9], v[11]);
EXPECT_EQ(v[7], v[11]);
EXPECT_EQ(v[2], v[4]+v[8]);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment