Commit a9e7292f authored by Quentin Khan's avatar Quentin Khan

utestFBasicParticle: creation

parent ccb4319f
#include <cassert>
#include "Components/FBasicParticle.hpp"
#include "Adaptive/new/FVariadicParticleContainer.hpp"
using FReal = double;
constexpr std::size_t Dim = 3;
namespace sd = scalfmm::details;
struct test_FBasicParticle_simple {
using Particle = FBasicParticle<FReal, Dim, scalfmm::pack<5, FReal> >;
using Container = FVariadicParticleContainer<Particle>;
void run() {
test_default_constructor();
test_variadic_constructor();
test_pull_push();
}
void test_default_constructor() {
Particle p;
static_assert(Particle::NbAttributes == 5, "Wrong count of attributes");
}
void test_variadic_constructor() {
const Particle::position_t pos(1.5,2.5,3.5);
Particle p(pos,1,2,3,4,5);
const auto pos2 = p.position();
assert(pos2[0] == pos[0]);
assert(pos2[1] == pos[1]);
assert(pos2[2] == pos[2]);
assert(get<3>(p) == 1);
assert(get<4>(p) == 2);
assert(get<5>(p) == 3);
assert(get<6>(p) == 4);
assert(get<7>(p) == 5);
double a = 1.5, b = 2.5, c = 3.5, d = 1, e = 2, f = 3, g = 4, h = 5;
Particle p2(std::make_tuple(1.5,2.5,3.5,1,2,3,4,5));
assert(get<3>(p2) == 1);
assert(get<4>(p2) == 2);
assert(get<5>(p2) == 3);
assert(get<6>(p2) == 4);
assert(get<7>(p2) == 5);
scalfmm::pack_expand_tuple<scalfmm::pack<8,const double&> > tup (a,b,c,d,e,f,g,h);
Particle p3(tup);
assert(get<3>(p3) == 1);
assert(get<4>(p3) == 2);
assert(get<5>(p3) == 3);
assert(get<6>(p3) == 4);
assert(get<7>(p3) == 5);
}
void test_pull_push() {
Particle p({2.3,3.4,4.5}, 5, 6, 7, 8, 9);
Container container;
Container other_container;
container.push(p);
other_container.push(container[0]);
assert(Particle(container[0]) == p);
assert(container.size() == 1);
assert(Particle(other_container[0]) == p);
}
};
int main() {
test_FBasicParticle_simple().run();
}
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