From 9c454d8dfc7f193e7d40ccd2e14e187587f3f626 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Mon, 3 Aug 2020 21:52:23 +0200 Subject: [PATCH] rm Tests/Functional/Std, now entirely replaced by new engine --- Tests/Functional/CMakeLists.txt | 1 - Tests/Functional/Std/CMakeLists.txt | 26 -- Tests/Functional/Std/IStandardTest.cpp | 24 -- Tests/Functional/Std/IStandardTest.h | 42 --- Tests/Functional/Std/StandardTestCatalog.cpp | 376 ------------------- Tests/Functional/Std/StandardTestCatalog.h | 47 --- Tests/Functional/Std/StandardTestInfo.cpp | 47 --- Tests/Functional/Std/StandardTestInfo.h | 46 --- Tests/Functional/Std/StandardTestService.cpp | 83 ---- Tests/Functional/Std/StandardTestService.h | 53 --- 10 files changed, 745 deletions(-) delete mode 100644 Tests/Functional/Std/CMakeLists.txt delete mode 100644 Tests/Functional/Std/IStandardTest.cpp delete mode 100644 Tests/Functional/Std/IStandardTest.h delete mode 100644 Tests/Functional/Std/StandardTestCatalog.cpp delete mode 100644 Tests/Functional/Std/StandardTestCatalog.h delete mode 100644 Tests/Functional/Std/StandardTestInfo.cpp delete mode 100644 Tests/Functional/Std/StandardTestInfo.h delete mode 100644 Tests/Functional/Std/StandardTestService.cpp delete mode 100644 Tests/Functional/Std/StandardTestService.h diff --git a/Tests/Functional/CMakeLists.txt b/Tests/Functional/CMakeLists.txt index 4f94caf38af..a460717b11c 100644 --- a/Tests/Functional/CMakeLists.txt +++ b/Tests/Functional/CMakeLists.txt @@ -4,7 +4,6 @@ include_directories(${CMAKE_SOURCE_DIR}/Tests/Functional/TestMachinery) -add_subdirectory(Std) add_subdirectory(Core) add_subdirectory(Fit) diff --git a/Tests/Functional/Std/CMakeLists.txt b/Tests/Functional/Std/CMakeLists.txt deleted file mode 100644 index 0cffff6101a..00000000000 --- a/Tests/Functional/Std/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -############################################################################ -# CMakeLists.txt file for building libBornAgainCore library -############################################################################ - -set(library_name BornAgainTestMachinery) - -file(GLOB source_files "*.cpp") - -if(WIN32) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBA_CORE_BUILD_DLL") -endif() - -add_library(${library_name} SHARED ${source_files}) -target_link_libraries(${library_name} ${BornAgainCore_LIBRARY} ${CMAKE_THREAD_LIBS_INIT}) - -set_target_properties(${library_name} PROPERTIES PREFIX ${libprefix} SUFFIX ${libsuffix}) -set(${library_name}_LIBRARY_TYPE SHARED) - -set(${library_name}_INCLUDE_DIRS ${include_dirs} PARENT_SCOPE) -set(${library_name}_LIBRARY ${library_name} PARENT_SCOPE) - - -if(APPLE AND BORNAGAIN_APPLE_BUNDLE) - set(link_flags "-Wl,-rpath,@loader_path/../../Frameworks") - set_target_properties(${library_name} PROPERTIES LINK_FLAGS ${link_flags}) -endif() diff --git a/Tests/Functional/Std/IStandardTest.cpp b/Tests/Functional/Std/IStandardTest.cpp deleted file mode 100644 index 5e1a7027caf..00000000000 --- a/Tests/Functional/Std/IStandardTest.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// ************************************************************************** // -// -// BornAgain: simulate and fit scattering at grazing incidence -// -//! @file Tests/Functional/Std/IStandardTest.cpp -//! @brief Defines pure virtual base class IStandardTest. -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************** // - -#include "Tests/Functional/Std/IStandardTest.h" -#include "Core/Simulation/Simulation.h" - -IStandardTest::IStandardTest(const std::string& name, const Simulation& simulation, - double threshold) - : m_name(name), m_reference_simulation(simulation.clone()), m_threshold(threshold) -{ -} - -IStandardTest::~IStandardTest() = default; // needs sizeof(Simulation) diff --git a/Tests/Functional/Std/IStandardTest.h b/Tests/Functional/Std/IStandardTest.h deleted file mode 100644 index a673ab664c1..00000000000 --- a/Tests/Functional/Std/IStandardTest.h +++ /dev/null @@ -1,42 +0,0 @@ -// ************************************************************************** // -// -// BornAgain: simulate and fit scattering at grazing incidence -// -//! @file Tests/Functional/Std/IStandardTest.h -//! @brief Defines pure virtual base class IStandardTest. -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************** // - -#ifndef BORNAGAIN_TESTS_FUNCTIONAL_STD_ISTANDARDTEST_H -#define BORNAGAIN_TESTS_FUNCTIONAL_STD_ISTANDARDTEST_H - -#include "Wrap/WinDllMacros.h" -#include <memory> -#include <string> - -class Simulation; - -//! Base class for tests that compare results with reference data. -//! @ingroup standard_samples - -class BA_CORE_API_ IStandardTest -{ -public: - IStandardTest(const std::string& name, const Simulation& simulation, double threshold); - - virtual ~IStandardTest(); - - virtual bool runTest() = 0; - -protected: - std::string m_name; - std::unique_ptr<Simulation> m_reference_simulation; - double m_threshold; -}; - -#endif // BORNAGAIN_TESTS_FUNCTIONAL_STD_ISTANDARDTEST_H diff --git a/Tests/Functional/Std/StandardTestCatalog.cpp b/Tests/Functional/Std/StandardTestCatalog.cpp deleted file mode 100644 index bb39acd3d5c..00000000000 --- a/Tests/Functional/Std/StandardTestCatalog.cpp +++ /dev/null @@ -1,376 +0,0 @@ -// ************************************************************************** // -// -// BornAgain: simulate and fit scattering at grazing incidence -// -//! @file Tests/Functional/Std/StandardTestCatalog.cpp -//! @brief Implements class StandardTestCatalog. -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************** // - -#include "Tests/Functional/Std/StandardTestCatalog.h" -#include "Fit/Tools/StringUtils.h" -#include <iostream> - -StandardTestCatalog::StandardTestCatalog() -{ - add("FormFactors", "Test of all form factors defined", "MiniGISAS", "ParticleInTheAirBuilder", - 2e-10); - - add("FormFactorsWithAbsorption", "Test of all form factors defined, absorption case", - "MiniGISAS_v2", "LayersWithAbsorptionBuilder", 2e-10); - - add("GISASAbsorptiveSLDLayers", "Test for SLD material in GISAS simulations", "MiniGISAS", - "LayersWithAbsorptionBySLDBuilder", 2e-10); - - add("CylindersAndPrisms", "Mixture of cylinders and prisms without interference", "MiniGISAS", - "CylindersAndPrismsBuilder", 2e-10); - - add("RadialParaCrystal", "Interference function of radial paracrystal", "MiniGISAS", - "RadialParaCrystalBuilder", 2e-10); - - add("HardDisk", "Interference function of hard disk Percus-Yevick", "MiniGISAS", - "HardDiskBuilder", 2e-10); - - add("Basic2DParaCrystal", - "Interference function of basic 2D paracrystal with variety of FT distributions", - "MiniGISAS", "Basic2DParaCrystalBuilder", 2e-10); - - add("HexParaCrystal", "Interference function of 2D hexagonal paracrystal", "MiniGISAS", - "HexParaCrystalBuilder", 2e-10); - - add("Lattice1D", "Interference function of 21D lattice", "MiniGISAS", "Lattice1DBuilder", - 2e-10); - - add("RectParaCrystal", "Interference function of 2D rectanguler paracrystal", "MiniGISAS", - "RectParaCrystalBuilder", 2e-10); - - // --- CoreShell --- - - add("CoreShellParticle", "Core shell particle", "MiniGISAS", "CoreShellParticleBuilder", 2e-10); - - add("CoreShellBoxRotateZandY", - "Rotation and translation of core shell box particle in 3 layers system", "MiniGISAS", - "CoreShellBoxRotateZandYBuilder", 2e-10); - - // --- - - add("MultiLayerWithRoughness", "Multilayer with roughness", "MiniGISAS", - "MultiLayerWithRoughnessBuilder", 2e-10); - - add("SquareLattice", "Interference function of 2D square lattice", "MiniGISAS", - "SquareLatticeBuilder", 2e-10); - - add("CenteredSquareLattice", "Interference function of 2D square lattice", "MiniGISAS", - "CenteredSquareLatticeBuilder", 2e-10); - - add("RotatedSquareLattice", "Interference function of rotated 2D square lattice", "MiniGISAS", - "RotatedSquareLatticeBuilder", 2e-10); - - add("FiniteSquareLattice", "Interference function of finite 2D square lattice", "MiniGISAS", - "FiniteSquareLatticeBuilder", 2e-10); - - add("SuperLattice", "Interference function of 2D superlattice", "MiniGISAS", - "SuperLatticeBuilder", 2e-10); - - add("RotatedPyramids", "Interference function of rotated 2D square lattice", "MiniGISAS", - "RotatedPyramidsBuilder", 2e-10); - - add("ThickAbsorptiveSampleWithRoughness", - "GISAS picture on extra long wavelength from thick absorptive sample with roughness", - "ExtraLongWavelengthGISAS", "ThickAbsorptiveSampleBuilder", 2e-10); - - // --- Compositions --- - - add("ParticleComposition", "Two layers of spheres at hex lattice", "MiniGISAS", - "ParticleCompositionBuilder", 2e-10); - - add("BoxCompositionRotateX", "Two boxes in particle composition rotated in X by 90 degrees", - "MiniGISAS", "BoxCompositionRotateXBuilder", 2e-10); - - add("BoxCompositionRotateY", "Two boxes in particle composition rotated in Y by 90 degrees", - "MiniGISAS", "BoxCompositionRotateYBuilder", 2e-10); - - add("BoxCompositionRotateZ", "Two boxes in particle composition rotated in Z by 90 degrees", - "MiniGISAS", "BoxCompositionRotateZBuilder", 2e-10); - - add("BoxCompositionRotateZandY", - "Two boxes in particle composition rotated in Z and Y by 90 degrees", "MiniGISAS", - "BoxCompositionRotateZandYBuilder", 2e-10); - - add("BoxStackComposition", - "Two different boxes are first rotated and then composed, composition is then rotated.", - "MiniGISAS", "BoxStackCompositionBuilder", 2e-10); - - // --- - - add("CylindersWithSizeDistribution", "Cylinders in BA with size distributions", "MiniGISAS", - "CylindersWithSizeDistributionBuilder", 2e-10); - - add("TwoTypesCylindersDistribution", "Cylinders in BA with size distributions", "MiniGISAS", - "TwoTypesCylindersDistributionBuilder", 2e-10); - - add("RotatedPyramidsDistribution", "Rotated pyramids distribution", "MiniGISAS", - "RotatedPyramidsDistributionBuilder", 2e-10); - - add("SpheresWithLimitsDistribution", - "Spherical particles with the distribution applied to the radius and RealLimits defined.", - "MiniGISAS", "SpheresWithLimitsDistributionBuilder", 2e-10); - - add("ConesWithLimitsDistribution", - "Spherical particles with the distribution applied to the radius and RealLimits defined.", - "MiniGISAS", "ConesWithLimitsDistributionBuilder", 2e-10); - - add("LinkedBoxDistribution", - "Distribution of boxes with main parameter and two linked parameters.", "MiniGISAS", - "LinkedBoxDistributionBuilder", 2e-10); - - // --- - - add("BeamDivergence", "Cylinders in BA in the presence of beam divergence", - "MiniGISASBeamDivergence", "CylindersInBABuilder", 2e-10); - - add("DetectorResolution", "Cylinders in BA with detector resolution", - "MiniGISASDetectorResolution", "CylindersInBABuilder", 2e-10); - - add("MultipleLayout", "Two types of particles in different layouts", "MiniGISAS", - "MultipleLayoutBuilder", 2e-10); - - add("ApproximationDA", "Size distribution model: decoupling approximation", "MiniGISAS", - "SizeDistributionDAModelBuilder", 2e-10); - - add("ApproximationLMA", "Size distribution model: local monodisperse approximation", - "MiniGISAS", "SizeDistributionLMAModelBuilder", 2e-10); - - add("ApproximationSSCA", "Size distribution model: size space coupling approximation", - "MiniGISAS", "SizeDistributionSSCAModelBuilder", 2e-10); - - add("CylindersInSSCA", "Size spacing correlation approximation", "MiniGISAS", - "CylindersInSSCABuilder", 2e-10); - - add("CosineRipple", "Cosine ripple within radial paracrystal model", "MiniGISAS", - "CosineRippleBuilder", 2e-10); - - add("TriangularRipple", "Triangular ripple within radial paracrystal model", "MiniGISAS", - "TriangularRippleBuilder", 2e-10); - - add("AsymRipple", "Triangular ripple with asymetry within radial paracrystal model", - "MiniGISAS", "AsymRippleBuilder", 2e-10); - - add("MesoCrystal", "Cylindrical mesocrystal composed of spherical nano particles", "MiniGISAS", - "MesoCrystalBuilder", 2e-10); - - add("CustomMorphology", "Custom particle mixture a la isgisaxs morphology approach", - "MiniGISAS", "CustomMorphologyBuilder", 2e-10); - - add("TransformBox", "Rotated/translated box in 3 layers system", "MiniGISAS", - "TransformBoxBuilder", 1e-10); - - // polarized GISAS - - add("MagneticParticleZeroField", "Magnetic cylinders with zero field", "MiniGISAS", - "MagneticParticleZeroFieldBuilder", 2e-10); - - add("MagneticSubstrateZeroField", "Magnetic substrate with zero field", - "MiniGISASPolarizationPP", "MagneticSubstrateZeroFieldBuilder", 2e-10); - - add("MagneticRotation", "Rotated magnetic particle in magnetic substrate", - "MiniGISASPolarizationPM", "MagneticRotationBuilder", 2e-10); - - add("MagneticSpheres", "Magnetic spheres inside substrate", "MiniGISASPolarizationPM", - "MagneticSpheresBuilder", 2e-10); - - add("MagneticCylindersPP", "Magnetic cylinders on a substrate: ++ channel", - "MiniGISASPolarizationPP", "MagneticCylindersBuilder", 2e-10); - - add("MagneticCylindersPM", "Magnetic cylinders on a substrate: +- channel", - "MiniGISASPolarizationPM", "MagneticCylindersBuilder", 2e-10); - - add("MagneticCylindersMP", "Magnetic cylinders on a substrate: -+ channel", - "MiniGISASPolarizationMP", "MagneticCylindersBuilder", 2e-10); - - add("MagneticCylindersMM", "Magnetic cylinders on a substrate: -- channel", - "MiniGISASPolarizationMM", "MagneticCylindersBuilder", 2e-10); - - add("MagneticSpheresInMagLayerPP", "Magnetic spheres in a magnetized layer, ++ channel", - "MiniGISASPolarizationPP", "MagneticLayerBuilder", 2e-10); - - add("MagneticSpheresInMagLayerMP", "Magnetic spheres in a magnetized layer, ++ channel", - "MiniGISASPolarizationMP", "MagneticLayerBuilder", 2e-10); - - // Masking - - add("SimulationWithMasks", "Various masks are added to the simulation", "GISASWithMasks", - "CylindersAndPrismsBuilder", 1e-10); - - // Various rectangular detector alignment - - add("RectDetectorGeneric", "Various masks are added to the simulation", "RectDetectorGeneric", - "CylindersInBABuilder", 1e-10); - - add("RectDetectorPerpToSample", "Various masks are added to the simulation", - "RectDetectorPerpToSample", "CylindersInBABuilder", 1e-10); - - add("RectDetectorPerpToDirectBeam", "Various masks are added to the simulation", - "RectDetectorPerpToDirectBeam", "CylindersInBABuilder", 1e-10); - - add("RectDetectorPerpToReflectedBeam", "Various masks are added to the simulation", - "RectDetectorPerpToReflectedBeam", "CylindersInBABuilder", 1e-10); - - add("RectDetectorPerpToReflectedBeamDpos", "Various masks are added to the simulation", - "RectDetectorPerpToReflectedBeamDpos", "CylindersInBABuilder", 1e-10); - - add("LargeCylindersMonteCarlo", "Large cylinders simulated with MonteCarlo integration", - "MiniGISASMonteCarlo", "LargeCylindersInDWBABuilder", 5e-1); - - add("SphericalDetWithRoi", "Spherical detector with ROI and mask defined", - "SphericalDetWithRoi", "CylindersAndPrismsBuilder", 1e-10); - - add("RectDetWithRoi", "Rectangular detector with ROI and mask defined", "RectDetWithRoi", - "CylindersAndPrismsBuilder", 1e-10); - - add("BoxesWithSpecular", "Boxes in square lattice including specular peak", "MiniGISASSpecular", - "BoxesSquareLatticeBuilder", 1e-10); - - add("RotatedCylinder", "Rotated cylinder in substrate", "MiniGISAS", "RotatedCylindersBuilder", - 1e-10); - - add("SlicedComposition", - "Spherical particle made of two different materials crossing interface", "MiniGISAS", - "SlicedCompositionBuilder", 1e-10); - - // Simulations with background - - add("ConstantBackground", "Constant background is added to the simulation", - "ConstantBackground", "CylindersInBABuilder", 1e-10); - - // Specular simulations - - add("HomogeneousTiNiSample", - "Specular simulation for 10 interchanging Ti-Ni homogeneous layers", "BasicSpecular", - "HomogeneousMultilayerBuilder", 1e-10); - - add("HomogeneousTiNiSampleWithAbsorption", - "Specular simulation for 10 interchanging Ti-Ni homogeneous " - "layers with absorptive SLD material", - "BasicSpecular", "PlainMultiLayerBySLDBuilder", 1e-10); - - add("RoughnessInSpecular", "Specular simulation with rough sample", "BasicSpecular", - "MultiLayerWithRoughnessBuilder", 2e-9); - - add("NCRoughnessInSpecular", "Specular simulation with rough sample (Nevot-Croce)", - "BasicSpecular", "MultiLayerWithNCRoughnessBuilder", 2e-9); - - add("GaussianBeamFootprint", - "Similar to HomogeneousTiNiSample, but with finite-sized gaussian beam", - "SpecularWithGaussianBeam", "HomogeneousMultilayerBuilder", 1e-10); - - add("SquareBeamFootprint", - "Similar to HomogeneousTiNiSample, but with finite-sized square beam", - "SpecularWithSquareBeam", "HomogeneousMultilayerBuilder", 1e-10); - - add("SpecularDivergentBeam", - "Simulates beam divergence both in wavelength and inclination angle", - "SpecularDivergentBeam", "HomogeneousMultilayerBuilder", 1e-10); - - add("RelativeResolutionTOF", - "Simulates q-defined reflectometry with a fixed relative q resolution", - "TOFRWithRelativeResolution", "PlainMultiLayerBySLDBuilder", 1e-10); - - add("SpecularWithSlicing", "Compares manual/automatic slicing in a sample with cylinders", - {"BasicSpecular", "BasicSpecular", "BasicSpecular", "BasicSpecularQ"}, - {"SlicedCylindersBuilder", "SLDSlicedCylindersBuilder", "AveragedSlicedCylindersBuilder", - "SLDSlicedCylindersBuilder"}, - 1e-10); - - add("InstrumentDefinitionComparison", - "Compares specular signal from q-defined, TOF and conventional instrument", - {"BasicSpecular", "BasicSpecularQ"}, - {"PlainMultiLayerBySLDBuilder", "PlainMultiLayerBySLDBuilder"}, 1e-10); - - add("TOFResolutionComparison", - "Compares specular signal from TOF instruments with pointwise and relative resolutions", - {"TOFRWithRelativeResolution", "TOFRWithPointwiseResolution"}, - {"PlainMultiLayerBySLDBuilder", "PlainMultiLayerBySLDBuilder"}, 1e-10); - - // polarized specular - - add("BasicSpecularPP", "Basic specular simulation on polarized sample, ++ channel", - "BasicSpecularPP", "SimpleMagneticLayerBuilder", 1e-10); - - add("BasicSpecularMM", "Basic specular simulation on polarized sample, -- channel", - "BasicSpecularMM", "SimpleMagneticLayerBuilder", 1e-10); - - add("PolarizedQAngleReflectivityPP", - "Compares specular signal from ++ channel for angular- and q-defined reflectivity", - {"BasicSpecularPP", "BasicQSpecularPP"}, - {"SimpleMagneticLayerBuilder", "SimpleMagneticLayerBuilder"}, 1e-10); - - add("PolarizedQAngleReflectivityMM", - "Compares specular signal from -- channel for angular- and q-defined reflectivity", - {"BasicSpecularMM", "BasicQSpecularMM"}, - {"SimpleMagneticLayerBuilder", "SimpleMagneticLayerBuilder"}, 1e-10); - - // off-specular simulation - - add("OffSpecularResonator", "Simulates resonator in OffSpec setup", "OffSpecMini", - "ResonatorBuilder", 1e-10); - - // depth probe simulation - - add("DepthProbeTest", "Test for basic functionality of depth probe", "BasicDepthProbe", - "HomogeneousMultilayerBuilder", 1e-10); -} - -//! Adds test description to the catalog. - -void StandardTestCatalog::add(const std::string& test_name, const std::string& test_description, - const std::string& simulation_name, - const std::string& sample_builder_name, double threshold) -{ - if (contains(test_name)) - throw std::runtime_error("StandardTestCatalog::add() -> Error. " - "Existing item '" - + test_name + "'"); - - m_catalog[test_name] = StandardTestInfo(test_name, test_description, simulation_name, - sample_builder_name, threshold); -} - -void StandardTestCatalog::add(const std::string& test_name, const std::string& test_description, - std::initializer_list<std::string> simulation_names, - std::initializer_list<std::string> sample_builder_names, - double threshold) -{ - if (contains(test_name)) - throw std::runtime_error("StandardTestCatalog::add() -> Error. " - "Existing item '" - + test_name + "'"); - - m_catalog[test_name] = - StandardTestInfo(test_name, test_description, std::move(simulation_names), - std::move(sample_builder_names), threshold); -} - -//! Returns test info for given test name. - -StandardTestInfo StandardTestCatalog::testInfo(const std::string& test_name) -{ - if (!contains(test_name)) - throw std::runtime_error("StandardTestCatalog::testInfo() -> Error. No info for " - "given name '" - + test_name + "'"); - - return m_catalog[test_name]; -} - -//! Returns true if catalog contains info for test with given name. - -bool StandardTestCatalog::contains(const std::string& test_name) -{ - return m_catalog.find(test_name) != m_catalog.end(); -} diff --git a/Tests/Functional/Std/StandardTestCatalog.h b/Tests/Functional/Std/StandardTestCatalog.h deleted file mode 100644 index 2bf2ac8cbd6..00000000000 --- a/Tests/Functional/Std/StandardTestCatalog.h +++ /dev/null @@ -1,47 +0,0 @@ -// ************************************************************************** // -// -// BornAgain: simulate and fit scattering at grazing incidence -// -//! @file Tests/Functional/Std/StandardTestCatalog.h -//! @brief Defines class StandardTestCatalog. -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************** // - -#ifndef BORNAGAIN_TESTS_FUNCTIONAL_STD_STANDARDTESTCATALOG_H -#define BORNAGAIN_TESTS_FUNCTIONAL_STD_STANDARDTESTCATALOG_H - -#include "Tests/Functional/Std/StandardTestInfo.h" -#include "Wrap/WinDllMacros.h" -#include <map> - -//! @class StandardTestCatalog -//! @ingroup standard_samples -//! @brief Catalog with the description of standard functional tests. - -class BA_CORE_API_ StandardTestCatalog -{ -public: - StandardTestCatalog(); - - StandardTestInfo testInfo(const std::string& test_name); - - bool contains(const std::string& test_name); - -private: - void add(const std::string& test_name, const std::string& test_description, - const std::string& simulation_name, const std::string& sample_builder_name, - double threshold); - - void add(const std::string& test_name, const std::string& test_description, - std::initializer_list<std::string> simulation_names, - std::initializer_list<std::string> sample_builder_name, double threshold); - - std::map<std::string, StandardTestInfo> m_catalog; -}; - -#endif // BORNAGAIN_TESTS_FUNCTIONAL_STD_STANDARDTESTCATALOG_H diff --git a/Tests/Functional/Std/StandardTestInfo.cpp b/Tests/Functional/Std/StandardTestInfo.cpp deleted file mode 100644 index bbba02fcd75..00000000000 --- a/Tests/Functional/Std/StandardTestInfo.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// ************************************************************************** // -// -// BornAgain: simulate and fit scattering at grazing incidence -// -//! @file Tests/Functional/Std/StandardTestInfo.cpp -//! @brief Implements class SimulationInfo. -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************** // - -#include "Tests/Functional/Std/StandardTestInfo.h" -#include <stdexcept> - -StandardTestInfo::StandardTestInfo() : m_threshold(0.0) {} - -StandardTestInfo::StandardTestInfo(const std::string& test_name, - const std::string& test_description, - const std::string& simulation_name, - const std::string& sample_builder_name, double threshold) - : m_test_name(test_name), m_test_description(test_description), - m_simulation_names({simulation_name}), m_sample_builder_names({sample_builder_name}), - m_threshold(threshold) -{ -} - -StandardTestInfo::StandardTestInfo(const std::string& test_name, - const std::string& test_description, - std::initializer_list<std::string> simulation_names, - std::initializer_list<std::string> sample_builder_names, - double threshold) - : m_test_name(test_name), m_test_description(test_description), - m_simulation_names(std::move(simulation_names)), - m_sample_builder_names(std::move(sample_builder_names)), m_threshold(threshold) -{ - if (m_simulation_names.size() != m_sample_builder_names.size()) - throw std::runtime_error("Error in StandardTestInfo::size(): inconsistent sizes of " - "simulation and builder name vectors"); -} - -size_t StandardTestInfo::size() const -{ - return m_simulation_names.size(); -} diff --git a/Tests/Functional/Std/StandardTestInfo.h b/Tests/Functional/Std/StandardTestInfo.h deleted file mode 100644 index fa2573ba1e9..00000000000 --- a/Tests/Functional/Std/StandardTestInfo.h +++ /dev/null @@ -1,46 +0,0 @@ -// ************************************************************************** // -// -// BornAgain: simulate and fit scattering at grazing incidence -// -//! @file Tests/Functional/Std/StandardTestInfo.h -//! @brief Defines class StandardTestInfo. -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************** // - -#ifndef BORNAGAIN_TESTS_FUNCTIONAL_STD_STANDARDTESTINFO_H -#define BORNAGAIN_TESTS_FUNCTIONAL_STD_STANDARDTESTINFO_H - -#include "Wrap/WinDllMacros.h" -#include <string> -#include <vector> - -//! @class StandardTestInfo -//! @ingroup standard_samples -//! @brief Collection of parameters necessary to run standard functional test. - -class BA_CORE_API_ StandardTestInfo -{ -public: - StandardTestInfo(); - StandardTestInfo(const std::string& test_name, const std::string& test_description, - const std::string& simulation_name, const std::string& sample_builder_name, - double threshold); - StandardTestInfo(const std::string& test_name, const std::string& test_description, - std::initializer_list<std::string> simulation_names, - std::initializer_list<std::string> sample_builder_names, double threshold); - - size_t size() const; - - std::string m_test_name; - std::string m_test_description; - std::vector<std::string> m_simulation_names; - std::vector<std::string> m_sample_builder_names; - double m_threshold; -}; - -#endif // BORNAGAIN_TESTS_FUNCTIONAL_STD_STANDARDTESTINFO_H diff --git a/Tests/Functional/Std/StandardTestService.cpp b/Tests/Functional/Std/StandardTestService.cpp deleted file mode 100644 index 508dc062f58..00000000000 --- a/Tests/Functional/Std/StandardTestService.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// ************************************************************************** // -// -// BornAgain: simulate and fit scattering at grazing incidence -// -//! @file Tests/Functional/Std/StandardTestService.cpp -//! @brief Defines class StandardTestService. -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************** // - -#include "Tests/Functional/Std/StandardTestService.h" -#include "Core/Multilayer/IMultiLayerBuilder.h" -#include "Core/Multilayer/MultiLayer.h" -#include "Core/StandardSamples/SampleBuilderFactory.h" -#include "Core/StandardSamples/SimulationFactory.h" -#include "Tests/Functional/Std/IStandardTest.h" -#include "Tests/Functional/Std/StandardTestCatalog.h" -#include <cassert> -#include <iostream> - -namespace -{ - -//! Returns test full name, composed from the test name and the name of sample builder. - -std::string fullTestName(const std::string& test_name, const std::string& builder_name) -{ - std::string result = test_name; - - if (builder_name != "SampleBuilder") - result += "_" + builder_name; - - return result; -} - -} // namespace - -//! Runs test corresponding to given command line parameters, returns true if success. - -bool StandardTestServiceBase::execute(int argc, char** argv) -{ - assert(argc > 1); - StandardTestInfo info = StandardTestCatalog().testInfo(argv[1]); - assert(!info.m_test_name.empty()); - assert(info.size() == 1); - - std::unique_ptr<IMultiLayerBuilder> builder( - SampleBuilderFactory().createItem(info.m_sample_builder_names.front())); - - size_t n_subtests = builder->size(); - int number_of_failed_tests = 0; - - for (size_t sample_index = 0; sample_index < builder->size(); ++sample_index) { - std::cout << "Run std test " << info.m_test_name << ", subtest " << sample_index << "/" - << builder->size() << ": " << builder->getName() << "\n"; - - std::unique_ptr<Simulation> simulation( - SimulationFactory().createItem(info.m_simulation_names.front())); - - std::unique_ptr<MultiLayer> sample(builder->createSample(sample_index)); - simulation->setSample(*sample); - - std::string test_name = fullTestName(info.m_test_name, builder->getName()); - - std::unique_ptr<IStandardTest> test( - createStdTest(test_name, *simulation, info.m_threshold)); - - if (!test->runTest()) { - std::cout << "subtest " << sample_index << " failed\n"; - ++number_of_failed_tests; - } - } - - if (number_of_failed_tests) - std::cout << "summary: " << number_of_failed_tests << " of " << n_subtests - << " subtests failed\n"; - - return number_of_failed_tests == 0; -} diff --git a/Tests/Functional/Std/StandardTestService.h b/Tests/Functional/Std/StandardTestService.h deleted file mode 100644 index 718e2b7b6e0..00000000000 --- a/Tests/Functional/Std/StandardTestService.h +++ /dev/null @@ -1,53 +0,0 @@ -// ************************************************************************** // -// -// BornAgain: simulate and fit scattering at grazing incidence -// -//! @file Tests/Functional/Std/StandardTestService.h -//! @brief Defines class StandardTestService. -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************** // - -#ifndef BORNAGAIN_TESTS_FUNCTIONAL_STD_STANDARDTESTSERVICE_H -#define BORNAGAIN_TESTS_FUNCTIONAL_STD_STANDARDTESTSERVICE_H - -#include "Wrap/WinDllMacros.h" -#include <string> -class IStandardTest; -class Simulation; - -//! Main class to run standard functional test from standalone executable. -//! @ingroup standard_samples - -class BA_CORE_API_ StandardTestServiceBase -{ -public: - virtual ~StandardTestServiceBase() = default; - bool execute(int argc, char** argv); - -private: - virtual IStandardTest* createStdTest(const std::string& name, const Simulation& simulation, - double threshold) = 0; -}; - -//! @brief -//! Extends main class to run standard functional test from standalone executable. -//! Concrete test type is templated. -//! @ingroup standard_samples - -template <typename T> class StandardTestService : public StandardTestServiceBase -{ - -private: - IStandardTest* createStdTest(const std::string& name, const Simulation& simulation, - double threshold) override - { - return new T(name, simulation, threshold); - } -}; - -#endif // BORNAGAIN_TESTS_FUNCTIONAL_STD_STANDARDTESTSERVICE_H -- GitLab