Skip to content
Snippets Groups Projects
Commit 37e74c45 authored by Matthias Puchner's avatar Matthias Puchner
Browse files

add unit tests for current state of formfactor -> python

necessary to guard following refactorings
parent 8dc7170e
No related branches found
No related tags found
1 merge request!65Refactor Distribution Handling
......@@ -8,7 +8,37 @@
#include "Sample/Correlations/FTDecay2D.h"
#include "Sample/Correlations/FTDistributions1D.h"
#include "Sample/Correlations/FTDistributions2D.h"
#include "Sample/HardParticle/FormFactorAnisoPyramid.h"
#include "Sample/HardParticle/FormFactorBar.h"
#include "Sample/HardParticle/FormFactorBox.h"
#include "Sample/HardParticle/FormFactorCantellatedCube.h"
#include "Sample/HardParticle/FormFactorCone.h"
#include "Sample/HardParticle/FormFactorCone6.h"
#include "Sample/HardParticle/FormFactorCosineRipple.h"
#include "Sample/HardParticle/FormFactorCuboctahedron.h"
#include "Sample/HardParticle/FormFactorCylinder.h"
#include "Sample/HardParticle/FormFactorDodecahedron.h"
#include "Sample/HardParticle/FormFactorDot.h"
#include "Sample/HardParticle/FormFactorEllipsoidalCylinder.h"
#include "Sample/HardParticle/FormFactorFullSphere.h"
#include "Sample/HardParticle/FormFactorFullSpheroid.h"
#include "Sample/HardParticle/FormFactorHemiEllipsoid.h"
#include "Sample/HardParticle/FormFactorHollowSphere.h"
#include "Sample/HardParticle/FormFactorIcosahedron.h"
#include "Sample/HardParticle/FormFactorLongBoxGauss.h"
#include "Sample/HardParticle/FormFactorLongBoxLorentz.h"
#include "Sample/HardParticle/FormFactorPrism3.h"
#include "Sample/HardParticle/FormFactorPrism6.h"
#include "Sample/HardParticle/FormFactorPyramid.h"
#include "Sample/HardParticle/FormFactorSawtoothRipple.h"
#include "Sample/HardParticle/FormFactorTetrahedron.h"
#include "Sample/HardParticle/FormFactorTruncatedCube.h"
#include "Sample/HardParticle/FormFactorTruncatedSphere.h"
#include "Sample/HardParticle/FormFactorTruncatedSpheroid.h"
#include "Sample/Slice/LayerRoughness.h"
#include "Sample/SoftParticle/FormFactorGauss.h"
#include "Sample/SoftParticle/FormFactorSphereGaussianRadius.h"
#include "Sample/SoftParticle/FormFactorSphereLogNormalRadius.h"
#include "Tests/GTestWrapper/google_test.h"
class PythonFormattingTest : public ::testing::Test {
......@@ -155,5 +185,115 @@ TEST_F(PythonFormattingTest, printParameterDistribution)
TEST_F(PythonFormattingTest, printLayerRoughness)
{
EXPECT_EQ(LayerRoughness(1.1, 2.2, 3.3).pythonConstructor(), "LayerRoughness(1.1, 2.2, 3.3*nm)");
EXPECT_EQ(LayerRoughness(1.1, 2.2, 3.3).pythonConstructor(),
"LayerRoughness(1.1, 2.2, 3.3*nm)");
}
TEST_F(PythonFormattingTest, printFormFactors)
{
// #baPool missing: class FormFactorCoreShell;
// #baPool missing: class FormFactorCrystal;
EXPECT_EQ(FormFactorAnisoPyramid(12.0, 14.0, 5.0, 55 * Units::deg).pythonConstructor(),
"FormFactorAnisoPyramid(12*nm, 14*nm, 5*nm, 55*deg)");
EXPECT_EQ(FormFactorDot(12.0).pythonConstructor(), "FormFactorDot(12*nm)");
EXPECT_EQ(FormFactorGaussSphere(12.0).pythonConstructor(), "FormFactorGaussSphere(12*nm)");
EXPECT_EQ(FormFactorHemiEllipsoid(6, 7, 5).pythonConstructor(),
"FormFactorHemiEllipsoid(6*nm, 7*nm, 5*nm)");
EXPECT_EQ(FormFactorHollowSphere(6, 7).pythonConstructor(),
"FormFactorHollowSphere(6*nm, 7*nm)");
EXPECT_EQ(FormFactorBox(6, 7, 5).pythonConstructor(), "FormFactorBox(6*nm, 7*nm, 5*nm)");
EXPECT_EQ(FormFactorCone(6, 5, 55 * Units::deg).pythonConstructor(),
"FormFactorCone(6*nm, 5*nm, 55*deg)");
EXPECT_EQ(FormFactorCone6(6, 5, 55 * Units::deg).pythonConstructor(),
"FormFactorCone6(6*nm, 5*nm, 55*deg)");
EXPECT_EQ(FormFactorCuboctahedron(10, 4, 0.7, 55 * Units::deg).pythonConstructor(),
"FormFactorCuboctahedron(10*nm, 4*nm, 0.7*nm, 55*deg)");
EXPECT_EQ(FormFactorCylinder(3, 5).pythonConstructor(), "FormFactorCylinder(3*nm, 5*nm)");
EXPECT_EQ(FormFactorDodecahedron(3).pythonConstructor(), "FormFactorDodecahedron(3*nm)");
EXPECT_EQ(FormFactorEllipsoidalCylinder(3, 4, 5).pythonConstructor(),
"FormFactorEllipsoidalCylinder(3*nm, 4*nm, 5*nm)");
EXPECT_EQ(FormFactorCantellatedCube(10, 2).pythonConstructor(),
"FormFactorCantellatedCube(10*nm, 2*nm)");
EXPECT_EQ(FormFactorFullSphere(5).pythonConstructor(), "FormFactorFullSphere(5*nm)");
EXPECT_EQ(FormFactorFullSpheroid(3, 5).pythonConstructor(),
"FormFactorFullSpheroid(3*nm, 5*nm)");
EXPECT_EQ(FormFactorIcosahedron(7).pythonConstructor(), "FormFactorIcosahedron(7*nm)");
EXPECT_EQ(FormFactorLongBoxGauss(6, 7, 5).pythonConstructor(),
"FormFactorLongBoxGauss(6*nm, 7*nm, 5*nm)");
EXPECT_EQ(FormFactorLongBoxLorentz(6, 7, 5).pythonConstructor(),
"FormFactorLongBoxLorentz(6*nm, 7*nm, 5*nm)");
EXPECT_EQ(FormFactorPrism3(6, 4).pythonConstructor(), "FormFactorPrism3(6*nm, 4*nm)");
EXPECT_EQ(FormFactorPrism6(3, 4).pythonConstructor(), "FormFactorPrism6(3*nm, 4*nm)");
EXPECT_EQ(FormFactorPyramid(10, 4, 60 * Units::deg).pythonConstructor(),
"FormFactorPyramid(10*nm, 4*nm, 60*deg)");
EXPECT_EQ(FormFactorTruncatedSphere(5, 3, 0).pythonConstructor(),
"FormFactorTruncatedSphere(5*nm, 3*nm, 0*nm)");
EXPECT_EQ(FormFactorTruncatedSpheroid(3, 5, 1.5, 0).pythonConstructor(),
"FormFactorTruncatedSpheroid(3*nm, 5*nm, 1.5, 0*nm)");
EXPECT_EQ(FormFactorTetrahedron(16, 4, 60 * Units::deg).pythonConstructor(),
"FormFactorTetrahedron(16*nm, 4*nm, 60*deg)");
EXPECT_EQ(FormFactorCosineRippleBox(100, 20, 4).pythonConstructor(),
"FormFactorCosineRippleBox(100*nm, 20*nm, 4*nm)");
EXPECT_EQ(FormFactorCosineRippleGauss(100, 20, 4).pythonConstructor(),
"FormFactorCosineRippleGauss(100*nm, 20*nm, 4*nm)");
EXPECT_EQ(FormFactorCosineRippleLorentz(100, 20, 4).pythonConstructor(),
"FormFactorCosineRippleLorentz(100*nm, 20*nm, 4*nm)");
EXPECT_EQ(FormFactorTruncatedCube(15, 6).pythonConstructor(),
"FormFactorTruncatedCube(15*nm, 6*nm)");
EXPECT_EQ(FormFactorSawtoothRippleBox(100, 20, 4, 0.3).pythonConstructor(),
"FormFactorSawtoothRippleBox(100*nm, 20*nm, 4*nm, 0.3*nm)");
EXPECT_EQ(FormFactorSawtoothRippleGauss(100, 20, 4, 0.3).pythonConstructor(),
"FormFactorSawtoothRippleGauss(100*nm, 20*nm, 4*nm, 0.3*nm)");
EXPECT_EQ(FormFactorSawtoothRippleLorentz(100, 20, 4, 0.3).pythonConstructor(),
"FormFactorSawtoothRippleLorentz(100*nm, 20*nm, 4*nm, 0.3*nm)");
EXPECT_EQ(FormFactorSphereGaussianRadius(100, 20).pythonConstructor(),
"FormFactorSphereGaussianRadius(100*nm, 20*nm)");
EXPECT_EQ(FormFactorBarGauss(100, 20, 4).pythonConstructor(),
"FormFactorBarGauss(100*nm, 20*nm, 4*nm)");
EXPECT_EQ(FormFactorBarLorentz(100, 20, 4).pythonConstructor(),
"FormFactorBarLorentz(100*nm, 20*nm, 4*nm)");
}
TEST_F(PythonFormattingTest, DISABLED_FormFactorSphereLogNormalRadius)
{
// #baPool ++ this fails already for non refactored code: 3rd parameter "sample" is not contained
// in the original py-ctor generation. The generated py code expects all three parameters (see
// libBornAgain.sample.py)!
// => decide what to do and enable the test
EXPECT_EQ(FormFactorSphereLogNormalRadius(100, 20, 10).pythonConstructor(),
"FormFactorSphereLogNormalRadius(100*nm, 20.0, 10)");
}
\ No newline at end of file
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