Make some changes
This commit is contained in:
parent
709d0c5411
commit
a24635ede0
@ -42,9 +42,12 @@
|
|||||||
* This macro calls the m_assert function which is a more informative
|
* This macro calls the m_assert function which is a more informative
|
||||||
* assertion function than the regular assert function from cassert.
|
* assertion function than the regular assert function from cassert.
|
||||||
* */
|
* */
|
||||||
#define ASSERT(expr, msg) m_assert(expr, #expr, __FUNCTION__, __FILE__, \
|
#define ASSERT(expr, msg) m_assert(expr, #expr, __METHOD_NAME__, __FILE__, \
|
||||||
__LINE__, msg)
|
__LINE__, msg)
|
||||||
|
|
||||||
|
#define __METHOD_NAME__ methodName(__PRETTY_FUNCTION__)
|
||||||
|
|
||||||
|
|
||||||
/** Code stolen from https://github.com/anderkve/FYS3150
|
/** Code stolen from https://github.com/anderkve/FYS3150
|
||||||
* Header: https://github.com/anderkve/FYS3150/blob/master/code_examples/compilation_linking/example_1/include/utils.hpp
|
* Header: https://github.com/anderkve/FYS3150/blob/master/code_examples/compilation_linking/example_1/include/utils.hpp
|
||||||
* Source: https://github.com/anderkve/FYS3150/blob/master/code_examples/compilation_linking/example_1/src/utils.cpp
|
* Source: https://github.com/anderkve/FYS3150/blob/master/code_examples/compilation_linking/example_1/src/utils.cpp
|
||||||
@ -105,4 +108,14 @@ void m_assert(bool expr,
|
|||||||
* */
|
* */
|
||||||
bool arma_vector_close_to(arma::vec &a, arma::vec &b, double tol=1e-8);
|
bool arma_vector_close_to(arma::vec &a, arma::vec &b, double tol=1e-8);
|
||||||
|
|
||||||
|
|
||||||
|
static inline std::string methodName(const std::string& prettyFunction)
|
||||||
|
{
|
||||||
|
size_t colons = prettyFunction.find("::");
|
||||||
|
size_t begin = prettyFunction.substr(0,colons).rfind(" ") + 1;
|
||||||
|
size_t end = prettyFunction.rfind("(") - begin;
|
||||||
|
|
||||||
|
return prettyFunction.substr(begin,end) + "()";
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -17,7 +17,9 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
void test_PenningTrap_external_E_field()
|
class PenningTrapTest {
|
||||||
|
public:
|
||||||
|
static void test_external_E_field()
|
||||||
{
|
{
|
||||||
PenningTrap trap;
|
PenningTrap trap;
|
||||||
|
|
||||||
@ -56,7 +58,7 @@ void test_PenningTrap_external_E_field()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void test_PenningTrap_external_B_field()
|
static void test_external_B_field()
|
||||||
{
|
{
|
||||||
// No point in testing at different points since it's not dependent on
|
// No point in testing at different points since it's not dependent on
|
||||||
// position.
|
// position.
|
||||||
@ -67,7 +69,8 @@ void test_PenningTrap_external_B_field()
|
|||||||
"Testing the external B field at (0,0,0)");
|
"Testing the external B field at (0,0,0)");
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_PenningTrap_force_on_particle()
|
|
||||||
|
static void test_force_on_particle()
|
||||||
{
|
{
|
||||||
PenningTrap trap;
|
PenningTrap trap;
|
||||||
arma::vec v{0.,0.,0.};
|
arma::vec v{0.,0.,0.};
|
||||||
@ -92,7 +95,7 @@ void test_PenningTrap_force_on_particle()
|
|||||||
"particle at (0,3,4).");
|
"particle at (0,3,4).");
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_PenningTrap_total_force_external()
|
static void test_total_force_external()
|
||||||
{
|
{
|
||||||
PenningTrap trap;
|
PenningTrap trap;
|
||||||
trap.add_particle(Particle(1.,40.,arma::vec{1.,2.,3.},
|
trap.add_particle(Particle(1.,40.,arma::vec{1.,2.,3.},
|
||||||
@ -105,7 +108,7 @@ void test_PenningTrap_total_force_external()
|
|||||||
"(1,2,3) with velocity (3,4,5)");
|
"(1,2,3) with velocity (3,4,5)");
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_PenningTrap_total_force_particles()
|
static void test_total_force_particles()
|
||||||
{
|
{
|
||||||
PenningTrap trap;
|
PenningTrap trap;
|
||||||
trap.add_particle(Particle(1.,40.,arma::vec{0.,0.,0.},
|
trap.add_particle(Particle(1.,40.,arma::vec{0.,0.,0.},
|
||||||
@ -130,13 +133,15 @@ void test_PenningTrap_total_force_particles()
|
|||||||
"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.");
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
test_PenningTrap_external_E_field();
|
PenningTrapTest::test_external_E_field();
|
||||||
test_PenningTrap_external_B_field();
|
PenningTrapTest::test_external_B_field();
|
||||||
test_PenningTrap_force_on_particle();
|
PenningTrapTest::test_force_on_particle();
|
||||||
test_PenningTrap_total_force_external();
|
PenningTrapTest::test_total_force_external();
|
||||||
test_PenningTrap_total_force_particles();
|
PenningTrapTest::test_total_force_particles();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user