File: CompoundTest.cpp

package info (click to toggle)
bornagain 23.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 103,936 kB
  • sloc: cpp: 423,131; python: 40,997; javascript: 11,167; awk: 630; sh: 318; ruby: 173; xml: 130; makefile: 51; ansic: 24
file content (32 lines) | stat: -rw-r--r-- 1,072 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "Sample/HardParticle/Sphere.h"

#include "Sample/Material/MaterialFactoryFuncs.h"
#include "Sample/Particle/Compound.h"
#include "Sample/Particle/Particle.h"
#include "Sample/Scattering/Rotations.h"
#include "Tests/GTestWrapper/google_test.h"

TEST(Compound, CompoundDefaultConstructor)
{
    std::unique_ptr<Compound> composition(new Compound);
    std::vector<R3> positions;
    positions.emplace_back();
    EXPECT_EQ(0u, composition->nbrParticles());
}

TEST(Compound, CompoundClone)
{
    Compound composition;
    R3 position = R3(1.0, 1.0, 1.0);
    Material material = RefractiveMaterial("Vacuum", 0.0, 0.0);
    Sphere ff(5.);
    Particle particle(material, ff);
    composition.addComponent(particle, position);

    std::unique_ptr<Compound> clone(composition.clone());
    std::vector<const INode*> children = clone->nodeChildren();
    EXPECT_EQ(children.size(), 1u);
    const auto* p_particle = dynamic_cast<const IParticle*>(children[0]);
    EXPECT_EQ(p_particle->rotation(), nullptr);
    EXPECT_EQ(p_particle->particlePosition(), position);
}