Skip to content
Snippets Groups Projects
Commit 3dd65775 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

rm trivial tests from Tests/Sample

parent 6a1c0f4e
No related branches found
No related tags found
1 merge request!403rm pointless tests
#include "Sample/Particle/Crystal.h"
#include "Sample/Lattice/BakeLattice.h"
#include "Sample/Particle/ParticleComposition.h"
#include "Tests/GTestWrapper/google_test.h"
class CrystalTest : public ::testing::Test {
};
TEST_F(CrystalTest, getChildren)
{
Lattice3D lattice = bake::HexagonalLattice(1.0, 2.0);
ParticleComposition composition;
Crystal crystal(composition, lattice);
std::vector<const INode*> children = crystal.getChildren();
ASSERT_EQ(children.size(), 2u);
}
...@@ -5,16 +5,6 @@ ...@@ -5,16 +5,6 @@
class Lattice2DTest : public ::testing::Test { class Lattice2DTest : public ::testing::Test {
}; };
TEST_F(Lattice2DTest, basicLattice)
{
const double length1(1.0), length2(2.0), angle(3.0), rotangle(0.7);
BasicLattice2D lattice(length1, length2, angle, rotangle);
EXPECT_EQ(lattice.length1(), length1);
EXPECT_EQ(lattice.length2(), length2);
EXPECT_EQ(lattice.latticeAngle(), angle);
EXPECT_EQ(lattice.rotationAngle(), rotangle);
}
TEST_F(Lattice2DTest, basicLatticeClone) TEST_F(Lattice2DTest, basicLatticeClone)
{ {
const double length1(1.0), length2(2.0), angle(3.0), xi(4.0); const double length1(1.0), length2(2.0), angle(3.0), xi(4.0);
...@@ -26,27 +16,3 @@ TEST_F(Lattice2DTest, basicLatticeClone) ...@@ -26,27 +16,3 @@ TEST_F(Lattice2DTest, basicLatticeClone)
EXPECT_EQ(clone->latticeAngle(), angle); EXPECT_EQ(clone->latticeAngle(), angle);
EXPECT_EQ(clone->rotationAngle(), xi); EXPECT_EQ(clone->rotationAngle(), xi);
} }
TEST_F(Lattice2DTest, squareLatticeClone)
{
const double length(1.0), xi(4.0);
SquareLattice2D lattice(length, xi);
std::unique_ptr<Lattice2D> clone(lattice.clone());
EXPECT_EQ(clone->length1(), length);
EXPECT_EQ(clone->length2(), length);
EXPECT_DOUBLE_EQ(clone->latticeAngle(), M_PI / 2.0);
EXPECT_EQ(clone->rotationAngle(), xi);
}
TEST_F(Lattice2DTest, hexagonalLatticeClone)
{
const double length(1.0), xi(4.0);
HexagonalLattice2D lattice(length, xi);
std::unique_ptr<Lattice2D> clone(lattice.clone());
EXPECT_EQ(clone->length1(), length);
EXPECT_EQ(clone->length2(), length);
EXPECT_DOUBLE_EQ(clone->latticeAngle(), 2. * M_PI / 3.0);
EXPECT_EQ(clone->rotationAngle(), xi);
}
#include "Sample/Interface/LayerInterface.h"
#include "Sample/Interface/LayerRoughness.h"
#include "Sample/Material/MaterialFactoryFuncs.h"
#include "Sample/Multilayer/Layer.h"
#include "Tests/GTestWrapper/google_test.h"
#include <memory>
class LayerInterfaceTest : public ::testing::Test {
};
TEST_F(LayerInterfaceTest, createSmoothInterface)
{
std::unique_ptr<Layer> layer0(new Layer(HomogeneousMaterial("Vacuum", 0.0, 0.0)));
std::unique_ptr<Layer> layer1(new Layer(HomogeneousMaterial("Vacuum", 0.0, 0.0)));
std::unique_ptr<LayerInterface> interface(
LayerInterface::createSmoothInterface(layer0.get(), layer1.get()));
EXPECT_EQ(interface->topLayer(), layer0.get());
EXPECT_EQ(interface->bottomLayer(), layer1.get());
EXPECT_EQ(interface->getRoughness(), nullptr);
EXPECT_EQ(interface->getChildren().size(), 0u);
}
TEST_F(LayerInterfaceTest, createRoughInterface)
{
std::unique_ptr<Layer> layer0(new Layer(HomogeneousMaterial("Vacuum", 0.0, 0.0)));
std::unique_ptr<Layer> layer1(new Layer(HomogeneousMaterial("Vacuum", 0.0, 0.0)));
std::unique_ptr<LayerInterface> interface(LayerInterface::createRoughInterface(
layer0.get(), layer1.get(), LayerRoughness(1.0, 2.0, 3.0)));
EXPECT_EQ(interface->topLayer(), layer0.get());
EXPECT_EQ(interface->bottomLayer(), layer1.get());
EXPECT_EQ(interface->getRoughness()->getSigma(), 1.0);
std::vector<const INode*> children = interface->getChildren();
EXPECT_EQ(children.size(), 1u);
}
...@@ -4,31 +4,6 @@ ...@@ -4,31 +4,6 @@
class LayerRoughnessTest : public ::testing::Test { class LayerRoughnessTest : public ::testing::Test {
}; };
TEST_F(LayerRoughnessTest, LayerRoughnessInitial)
{
// test with default parameter
LayerRoughness roughness;
EXPECT_EQ(0.0, roughness.getSigma());
EXPECT_EQ(0.0, roughness.getHurstParameter());
EXPECT_EQ(0.0, roughness.getLatteralCorrLength());
// set new parameter
roughness.setSigma(1.1);
EXPECT_EQ(1.1, roughness.getSigma());
roughness.setHurstParameter(1.2);
EXPECT_EQ(1.2, roughness.getHurstParameter());
roughness.setLatteralCorrLength(1.3);
EXPECT_EQ(1.3, roughness.getLatteralCorrLength());
// test with given parameter
LayerRoughness roughness2(2.1, 2.2, 2.3);
EXPECT_EQ(2.1, roughness2.getSigma());
EXPECT_EQ(2.2, roughness2.getHurstParameter());
EXPECT_EQ(2.3, roughness2.getLatteralCorrLength());
}
// test clone LayerRoughness // test clone LayerRoughness
TEST_F(LayerRoughnessTest, LayerRoughnessClone) TEST_F(LayerRoughnessTest, LayerRoughnessClone)
{ {
......
...@@ -11,10 +11,6 @@ TEST_F(LayerTest, LayerGetAndSet) ...@@ -11,10 +11,6 @@ TEST_F(LayerTest, LayerGetAndSet)
{ {
Material vacuum = HomogeneousMaterial("Vacuum", 0, 0); Material vacuum = HomogeneousMaterial("Vacuum", 0, 0);
Layer layer(vacuum, 10 * Units::nm); Layer layer(vacuum, 10 * Units::nm);
EXPECT_EQ(vacuum, *layer.material());
EXPECT_EQ(0u, layer.layouts().size());
EXPECT_EQ(10, layer.thickness());
EXPECT_EQ(layer.numberOfLayouts(), 0u);
std::unique_ptr<Layer> clone(layer.clone()); std::unique_ptr<Layer> clone(layer.clone());
EXPECT_EQ(vacuum, *clone->material()); EXPECT_EQ(vacuum, *clone->material());
...@@ -22,34 +18,3 @@ TEST_F(LayerTest, LayerGetAndSet) ...@@ -22,34 +18,3 @@ TEST_F(LayerTest, LayerGetAndSet)
EXPECT_EQ(10, clone->thickness()); EXPECT_EQ(10, clone->thickness());
EXPECT_EQ(clone->numberOfLayouts(), 0u); EXPECT_EQ(clone->numberOfLayouts(), 0u);
} }
TEST_F(LayerTest, LayerAndDecoration)
{
Material vacuum = HomogeneousMaterial("Vacuum", 0, 0);
std::unique_ptr<ParticleLayout> layout1(new ParticleLayout());
Layer layer(vacuum, 10 * Units::nm);
layer.addLayout(*layout1);
EXPECT_EQ(layer.numberOfLayouts(), 1u);
ParticleLayout layout2;
layer.addLayout(layout2);
EXPECT_EQ(layer.numberOfLayouts(), 2u);
}
TEST_F(LayerTest, getChildren)
{
Layer layer(HomogeneousMaterial("Vacuum", 0.0, 0.0));
std::vector<const INode*> children = layer.getChildren();
EXPECT_EQ(children.size(), 0u);
// children after adding layout
layer.addLayout(ParticleLayout());
layer.addLayout(ParticleLayout());
children = layer.getChildren();
EXPECT_EQ(children.size(), 2u);
EXPECT_EQ(children.at(0), layer.layouts()[0]);
EXPECT_EQ(children.at(1), layer.layouts()[1]);
}
#include "Sample/Particle/MesoCrystal.h"
#include "Sample/HardParticle/FormFactorFullSphere.h"
#include "Sample/Lattice/BakeLattice.h"
#include "Sample/Particle/Crystal.h"
#include "Sample/Particle/ParticleComposition.h"
#include "Sample/Scattering/Rotations.h"
#include "Tests/GTestWrapper/google_test.h"
class MesoCrystalTest : public ::testing::Test {
};
TEST_F(MesoCrystalTest, getChildren)
{
Lattice3D lattice = bake::HexagonalLattice(1.0, 2.0);
ParticleComposition composition;
Crystal crystal(composition, lattice);
MesoCrystal meso(crystal, FormFactorFullSphere(1.0));
std::vector<const INode*> children = meso.getChildren();
EXPECT_EQ(children.size(), 2u);
// children when rotation is set
meso.setRotation(RotationY(45.));
children = meso.getChildren();
EXPECT_EQ(children.size(), 3u);
}
...@@ -32,16 +32,3 @@ TEST_F(ParticleCompositionTest, ParticleCompositionClone) ...@@ -32,16 +32,3 @@ TEST_F(ParticleCompositionTest, ParticleCompositionClone)
EXPECT_EQ(p_particle->rotation(), nullptr); EXPECT_EQ(p_particle->rotation(), nullptr);
EXPECT_EQ(p_particle->position(), position); EXPECT_EQ(p_particle->position(), position);
} }
TEST_F(ParticleCompositionTest, getChildren)
{
Material material = HomogeneousMaterial("Vacuum", 0.0, 0.0);
ParticleComposition composition;
composition.addParticle(Particle(material, FormFactorFullSphere(1.0)));
composition.addParticle(Particle(material, FormFactorFullSphere(1.0)));
composition.setRotation(RotationY(45.));
std::vector<const INode*> children = composition.getChildren();
EXPECT_EQ(children.size(), 3u);
}
...@@ -58,19 +58,3 @@ TEST_F(ParticleCoreShellTest, ComplexCoreShellClone) ...@@ -58,19 +58,3 @@ TEST_F(ParticleCoreShellTest, ComplexCoreShellClone)
EXPECT_EQ(clone->coreParticle()->position(), relative_pos); EXPECT_EQ(clone->coreParticle()->position(), relative_pos);
delete clone; delete clone;
} }
TEST_F(ParticleCoreShellTest, getChildren)
{
Material mat = HomogeneousMaterial("mat", 0.0, 0.0);
Particle core(mat, FormFactorBox(1.0, 1.0, 1.0));
Particle shell(mat, FormFactorFullSphere(1.0));
ParticleCoreShell coreshell(shell, core);
std::vector<const INode*> children = coreshell.getChildren();
ASSERT_EQ(children.size(), 2u);
// adding rotation and checking children again
coreshell.setRotation(RotationZ(0.1));
children = coreshell.getChildren();
EXPECT_EQ(children.size(), 3u);
}
...@@ -29,37 +29,3 @@ TEST_F(ParticleTest, Constructors) ...@@ -29,37 +29,3 @@ TEST_F(ParticleTest, Constructors)
auto p3_formfactor = std::unique_ptr<IFormFactor>(p3->createFormFactor()); auto p3_formfactor = std::unique_ptr<IFormFactor>(p3->createFormFactor());
EXPECT_TRUE(dynamic_cast<FormFactorDecoratorMaterial*>(p3_formfactor.get())); EXPECT_TRUE(dynamic_cast<FormFactorDecoratorMaterial*>(p3_formfactor.get()));
} }
TEST_F(ParticleTest, setters)
{
Material mat = HomogeneousMaterial("Any", 10e-2, 10e-5);
FormFactorFullSphere sphere(2.1);
RotationY transform(45. * Units::deg);
Particle particle(mat);
EXPECT_EQ(mat, *particle.material());
EXPECT_EQ(nullptr, particle.rotation());
particle.setRotation(transform);
EXPECT_TRUE(nullptr != particle.rotation());
std::unique_ptr<Particle> particle2(particle.clone());
EXPECT_EQ(mat, *particle2->material());
EXPECT_TRUE(nullptr != particle2->rotation());
}
TEST_F(ParticleTest, getChildren)
{
Material mat = HomogeneousMaterial("Vacuum", 0, 0);
FormFactorFullSphere sphere(2.1);
// Checking children of particle (no rotation)
std::unique_ptr<Particle> particle(new Particle(mat, sphere));
std::vector<const INode*> children = particle->getChildren();
EXPECT_EQ(children.size(), 1u);
// Checking children of particle (with rotation)
particle = std::make_unique<Particle>(mat, sphere, RotationY(45.));
children = particle->getChildren();
EXPECT_EQ(children.size(), 2u);
}
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