Code indexing in gitaly is broken and leads to code not being visible to the user. We work on the issue with highest priority.

Skip to content
Snippets Groups Projects
Commit af52c9e3 authored by ext-rogers_c's avatar ext-rogers_c
Browse files

Fix failing unit tests

parent 0df88e7e
No related branches found
No related tags found
No related merge requests found
......@@ -86,14 +86,15 @@ class OffsetFactory {
// generate a set of sector magnets; the geometry is defined so that they are
// exact sector magnets
Component* yieldComp2() {
std::cerr << "YIELDCOMP2" << std::endl;
double f = Physics::pi/20.;
Offset* off = new Offset(Offset::localCylindricalOffset("offset4", f, f, 2.*radius_m*sin(f)));
Offset* off = new Offset(
Offset::localCylindricalOffset("offset4", f, f, 2.*radius_m*sin(f)));
offVec_m.push_back(off);
MockComponent* mock = new MockComponent();
mock->geom_m = &off->getGeometry();
mockVec_m.push_back(mock);
return mock;
}
int i_m;
......@@ -239,6 +240,7 @@ TEST(RingTest, TestApply) {
OpalTestUtilities::SilenceTest silencer;
Ring ring("my_ring");
double metres = 1e-3;
try {
double radius = 2.*(2.*sin(Physics::pi/6.)+1.*sin(Physics::pi/3.)+1.0);
PartData data;
......@@ -258,18 +260,22 @@ TEST(RingTest, TestApply) {
for (double x = -1.0001; x < 2.; x += 0.1) {
double y = -2.2;
Vector_t pos(x, y, -0.5);
pos *= metres;
Vector_t zero(0.0);
Vector_t centroid(0., 0., 0), B(0., 0., 0), E(0., 0., 0);
double t = 0;
// std::cout << pos << " ** " << std::flush;
std::cout << "Apply pos:" << pos << std::endl;
EXPECT_FALSE(ring.apply(pos, zero, t, E, B));
// std::cout << B << " " << E << std::endl;
std::cout << "Yields B: " << B << " E: " << E << std::endl;
Vector_t BRef(0.0, 0.0, 0.0);
if (x > 0. and x < 1.)
BRef = Vector_t(x-1., y+2., -0.5);
std::cout << "Expected B: " << BRef << std::endl;
for (int i = 0; i < 3; ++i) {
EXPECT_NEAR(B(i), BRef(i), 1e-6) << " for pos " << pos;
EXPECT_NEAR(E(i), -BRef(i), 1e-6) << " for pos " << pos;
EXPECT_NEAR(B(i), BRef(i), 1e-6)
<< "component " << i << " for pos " << pos;
EXPECT_NEAR(E(i), -BRef(i), 1e-6)
<< "component " << i << " for pos " << pos;
}
}
// check that we get something reasonable for all phi
......@@ -290,6 +296,7 @@ TEST(RingTest, TestApply2) {
OpalTestUtilities::SilenceTest silencer;
Ring ring("my_ring");
double metres = 1e-3;
try {
double radius = 1.5;
PartData data;
......@@ -307,6 +314,7 @@ TEST(RingTest, TestApply2) {
ring.lockRing();
for (double phi = 0.001; phi < 2.*Physics::pi+0.1; phi += Physics::pi/50.) {
Vector_t pos((radius+0.5)*sin(phi), (radius+0.5)*cos(phi), -0.5);
pos *= metres;
Vector_t centroid, B, E;
std::vector<RingSection*> sections = ring.getSectionsAt(pos);
EXPECT_FALSE(ring.apply(pos, Vector_t(0.0), 0., E, B));
......@@ -405,6 +413,7 @@ void testField(double s, double r, double y, double phi,
Vector_t pos(radius*sin(phi)+s*cos(phi)+r*sin(phi),
radius*cos(phi)-s*sin(phi)+r*cos(phi),
y);
pos *= 1e-3; // metres
ring.apply(pos, Vector_t(0.0), 0., E, B);
EXPECT_NEAR(B(0), bx, 1e-6);
EXPECT_NEAR(B(1), by, 1e-6);
......@@ -422,4 +431,4 @@ TEST(RingTest, TestApply3) {
testField(0.1, 0.15, 0.2, Physics::pi/6.,
3.*cos(Physics::pi/6)+1.*sin(Physics::pi/6),
-3.*sin(Physics::pi/6)+1.*cos(Physics::pi/6), 2., 1e-6);
}
\ No newline at end of file
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment