Use close_to
This commit is contained in:
parent
af2712cccd
commit
763a34ea8c
@ -10,13 +10,13 @@
|
|||||||
* @bug No known bugs
|
* @bug No known bugs
|
||||||
* */
|
* */
|
||||||
|
|
||||||
#include "PenningTrap.hpp"
|
|
||||||
#include "utils.hpp"
|
|
||||||
|
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "PenningTrap.hpp"
|
||||||
|
#include "utils.hpp"
|
||||||
|
|
||||||
class PenningTrapTest {
|
class PenningTrapTest {
|
||||||
public:
|
public:
|
||||||
static void test_external_E_field()
|
static void test_external_E_field()
|
||||||
@ -52,7 +52,7 @@ public:
|
|||||||
msg << "Testing the external E field at (" << std::setprecision(2)
|
msg << "Testing the external E field at (" << std::setprecision(2)
|
||||||
<< v(0) << "," << v(1) << "," << v(2) << ").";
|
<< v(0) << "," << v(1) << "," << v(2) << ").";
|
||||||
|
|
||||||
ASSERT(arma_vector_close_to(result, tests.at(i).second), msg.str());
|
ASSERT(close_to(result, tests.at(i).second), msg.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ public:
|
|||||||
PenningTrap trap;
|
PenningTrap trap;
|
||||||
arma::vec expected{0., 0., T};
|
arma::vec expected{0., 0., T};
|
||||||
arma::vec result = trap.external_B_field(arma::vec{0., 0., 0.});
|
arma::vec result = trap.external_B_field(arma::vec{0., 0., 0.});
|
||||||
ASSERT(arma_vector_close_to(expected, result),
|
ASSERT(close_to(expected, result),
|
||||||
"Testing the external B field at (0,0,0)");
|
"Testing the external B field at (0,0,0)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,14 +80,14 @@ public:
|
|||||||
// Test p0 and p1
|
// Test p0 and p1
|
||||||
arma::vec expected{-1., 0., 0.};
|
arma::vec expected{-1., 0., 0.};
|
||||||
arma::vec result = trap.force_on_particle(0, 1);
|
arma::vec result = trap.force_on_particle(0, 1);
|
||||||
ASSERT(arma_vector_close_to(expected, result),
|
ASSERT(close_to(expected, result),
|
||||||
"Testing the force on a particle at (0,0,0) from a "
|
"Testing the force on a particle at (0,0,0) from a "
|
||||||
"particle at (1,0,0).");
|
"particle at (1,0,0).");
|
||||||
|
|
||||||
// Test p0 and p2
|
// Test p0 and p2
|
||||||
expected = arma::vec{0, -.024, -.032};
|
expected = arma::vec{0, -.024, -.032};
|
||||||
result = trap.force_on_particle(0, 2);
|
result = trap.force_on_particle(0, 2);
|
||||||
ASSERT(arma_vector_close_to(expected, result),
|
ASSERT(close_to(expected, result),
|
||||||
"Testing the force on a particle at (0,0,0) from a "
|
"Testing the force on a particle at (0,0,0) from a "
|
||||||
"particle at (0,3,4).");
|
"particle at (0,3,4).");
|
||||||
}
|
}
|
||||||
@ -100,7 +100,7 @@ public:
|
|||||||
|
|
||||||
arma::vec expected{395.58954878, -270.15871624, -57.89115348};
|
arma::vec expected{395.58954878, -270.15871624, -57.89115348};
|
||||||
arma::vec result = trap.total_force_external(0);
|
arma::vec result = trap.total_force_external(0);
|
||||||
ASSERT(arma_vector_close_to(expected, result),
|
ASSERT(close_to(expected, result),
|
||||||
"Testing the total external force on a particle at "
|
"Testing the total external force on a particle at "
|
||||||
"(1,2,3) with velocity (3,4,5)");
|
"(1,2,3) with velocity (3,4,5)");
|
||||||
}
|
}
|
||||||
@ -113,7 +113,7 @@ public:
|
|||||||
|
|
||||||
arma::vec expected{0., 0., 0.};
|
arma::vec expected{0., 0., 0.};
|
||||||
arma::vec result = trap.total_force_particles(0);
|
arma::vec result = trap.total_force_particles(0);
|
||||||
ASSERT(arma_vector_close_to(expected, result),
|
ASSERT(close_to(expected, result),
|
||||||
"Testing the total force of all particles on particle 0 "
|
"Testing the total force of all particles on particle 0 "
|
||||||
"with only a single particle");
|
"with only a single particle");
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ public:
|
|||||||
|
|
||||||
expected = arma::vec(3, arma::fill::value(-3473.383325));
|
expected = arma::vec(3, arma::fill::value(-3473.383325));
|
||||||
result = trap.total_force_particles(0);
|
result = trap.total_force_particles(0);
|
||||||
ASSERT(arma_vector_close_to(expected, result),
|
ASSERT(close_to(expected, result),
|
||||||
"Testing the total force of all particles on particle 0 "
|
"Testing the total force of all particles on particle 0 "
|
||||||
"with 3 other particles.");
|
"with 3 other particles.");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user