Code indexing in gitaly is broken and leads to code not being visible to the user. We work on the issue with highest priority.

Skip to content
Snippets Groups Projects
Commit 6b08a261 authored by Christof Metzger-Kraus's avatar Christof Metzger-Kraus
Browse files

add silencer to all tests

parent 1a5bff88
No related branches found
No related tags found
No related merge requests found
Showing
with 344 additions and 186 deletions
/*
/*
* Copyright (c) 2014, Chris Rogers
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STFC nor the names of its contributors may be used to
* endorse or promote products derived from this software without specific
* 3. Neither the name of STFC nor the names of its contributors may be used to
* endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
......@@ -34,9 +34,13 @@
#include "BeamlineGeometry/StraightGeometry.h"
#include "AbsBeamline/Offset.h"
#include "opal_test_utilities/SilenceTest.h"
class SRotatedGeometry;
TEST(OffsetTest, TestConstructDestruct) {
OpalTestUtilities::SilenceTest silencer;
// Test default constructors (copy constructor/operator below)
Offset off1("Name");
try {
......@@ -52,6 +56,8 @@ TEST(OffsetTest, TestConstructDestruct) {
}
TEST(OffsetTest, TestGetSet) {
OpalTestUtilities::SilenceTest silencer;
// Check for typos in accessors/mutators
Vector_t ref(1., 2., 3.);
Vector_t test;
......@@ -101,6 +107,8 @@ void buildTestOffset(Vector_t endPos, Vector_t endDir,
}
TEST(OffsetTest, TestUpdateIdentityTransforms) {
OpalTestUtilities::SilenceTest silencer;
// Check we don't throw up on an identity transform about origin
// results are undefined, returns identity
buildTestOffset(Vector_t(0., 0., 0.), Vector_t(1., 0., 0.),
......@@ -112,6 +120,8 @@ TEST(OffsetTest, TestUpdateIdentityTransforms) {
}
TEST(OffsetTest, TestUpdateRotationsNotXY) {
OpalTestUtilities::SilenceTest silencer;
// Check we throw for a translation/rotation out of the midplane
EXPECT_THROW(buildTestOffset(Vector_t(1., 3., 1.), Vector_t(+1., 0., 0.),
0., 0., 0., "not x-y rotation"),
......@@ -122,6 +132,8 @@ TEST(OffsetTest, TestUpdateRotationsNotXY) {
}
TEST(OffsetTest, TestUpdateRotations) {
OpalTestUtilities::SilenceTest silencer;
// Check we get length right
buildTestOffset(Vector_t(1., 2., 0.), Vector_t(+1., 0., 0.),
atan2(2., 1.), 0., sqrt(5.), "length");
......@@ -154,6 +166,8 @@ TEST(OffsetTest, TestUpdateRotations) {
}
TEST(OffsetTest, TestCopy) {
OpalTestUtilities::SilenceTest silencer;
Offset off1("Name");
off1.setEndPosition(Vector_t(1., 3., 0.));
off1.setEndDirection(Vector_t(1., 4., 0.));
......@@ -172,6 +186,8 @@ TEST(OffsetTest, TestCopy) {
}
TEST(OffsetTest, TestRotateGetTheta) {
OpalTestUtilities::SilenceTest silencer;
// rotate and getTheta methods are (more or less) inverse
// we check a few examples by hand
Vector_t vecIn(1., 2., 0.);
......@@ -211,6 +227,8 @@ TEST(OffsetTest, TestRotateGetTheta) {
}
TEST(OffsetTest, TestBends) {
OpalTestUtilities::SilenceTest silencer;
double theta1 = Offset::float_tolerance*10.; // precision not great
double theta2 = Offset::float_tolerance/1000.;
Offset off = Offset::localCylindricalOffset("lco", theta1, 0., 3.);
......@@ -224,6 +242,8 @@ TEST(OffsetTest, TestBends) {
}
TEST(OffsetTest, TestLocalCylindricalOffset) {
OpalTestUtilities::SilenceTest silencer;
double theta = Physics::pi/3.;
Offset off1 = Offset::localCylindricalOffset("lco", theta, 0., 3.);
EXPECT_EQ(off1.getName(), "lco");
......@@ -253,6 +273,8 @@ TEST(OffsetTest, TestLocalCylindricalOffset) {
}
TEST(OffsetTest, TestGlobalCylindricalOffset) {
OpalTestUtilities::SilenceTest silencer;
double radius = 7.;
double phi = Physics::pi/3.;
double theta = Physics::pi/4.;
......@@ -269,8 +291,10 @@ TEST(OffsetTest, TestGlobalCylindricalOffset) {
}
TEST(OffsetTest, TestLocalCartesianOffset) {
OpalTestUtilities::SilenceTest silencer;
double theta = Physics::pi/6.;
Offset off1 = Offset::localCartesianOffset("lco",
Offset off1 = Offset::localCartesianOffset("lco",
3.*Vector_t(cos(theta), sin(theta), 0.),
10.*Vector_t(cos(theta/3.), sin(theta/3.), 0.));
EXPECT_EQ(off1.getName(), "lco");
......@@ -285,6 +309,8 @@ TEST(OffsetTest, TestLocalCartesianOffset) {
}
TEST(OffsetTest, TestGlobalCartesianOffset) {
OpalTestUtilities::SilenceTest silencer;
double theta = Physics::pi/3.;
Offset off1 = Offset::globalCartesianOffset("gco",
3.*Vector_t(cos(theta), sin(theta), 0.),
......@@ -298,5 +324,4 @@ TEST(OffsetTest, TestGlobalCartesianOffset) {
EXPECT_DOUBLE_EQ(off1.getEndDirection()(i),
10.*Vector_t(cos(theta/3.), sin(theta/3.), 0.)(i));
testOffset(off1, 0., 0., 0., "");
}
}
\ No newline at end of file
......@@ -34,6 +34,8 @@
#include "AbsBeamline/Ring.h"
#include "Utilities/OpalException.h"
#include "opal_test_utilities/SilenceTest.h"
#include <iostream>
#include <sstream>
......@@ -108,6 +110,8 @@ TEST(RingTest, TestConstructDestruct) {
}
TEST(RingTest, TestAppend1) {
OpalTestUtilities::SilenceTest silencer;
try {
double radius = 5.;
Ring ring("my_ring");
......@@ -141,6 +145,8 @@ TEST(RingTest, TestAppend1) {
}
TEST(RingTest, TestAppend2) {
OpalTestUtilities::SilenceTest silencer;
try {
double radius = 5.;
Ring ring("my_ring");
......@@ -174,6 +180,8 @@ TEST(RingTest, TestAppend2) {
}
TEST(RingTest, TestAppend3) {
OpalTestUtilities::SilenceTest silencer;
try {
double radius = 5.;
Ring ring("my_ring");
......@@ -194,6 +202,8 @@ TEST(RingTest, TestAppend3) {
}
TEST(RingTest, TestLatticeRInitPhiInit) {
OpalTestUtilities::SilenceTest silencer;
for (double phi = -2.*Physics::pi;
phi < 2.*Physics::pi;
phi += Physics::pi/6.) {
......@@ -226,6 +236,8 @@ TEST(RingTest, TestLatticeRInitPhiInit) {
// Check that we get the bounding box and rotation correct
TEST(RingTest, TestApply) {
OpalTestUtilities::SilenceTest silencer;
Ring ring("my_ring");
try {
double radius = 2.*(2.*sin(Physics::pi/6.)+1.*sin(Physics::pi/3.)+1.0);
......@@ -275,6 +287,8 @@ TEST(RingTest, TestApply) {
// Check that we get the bounding box correct - for exact sector geometry
TEST(RingTest, TestApply2) {
OpalTestUtilities::SilenceTest silencer;
Ring ring("my_ring");
try {
double radius = 1.5;
......@@ -399,6 +413,8 @@ void testField(double s, double r, double y, double phi,
}
TEST(RingTest, TestApply3) {
OpalTestUtilities::SilenceTest silencer;
testField(0.1, 0., 0.2, 0., 3., 1., 2., 1e-6);
testField(0.1, 0., 0.2, Physics::pi, -3., -1., 2., 1e-6);
testField(0.1, 0., 0.2, Physics::pi/2., 1., -3., 2., 1e-6);
......@@ -406,4 +422,4 @@ TEST(RingTest, TestApply3) {
testField(0.1, 0.15, 0.2, Physics::pi/6.,
3.*cos(Physics::pi/6)+1.*sin(Physics::pi/6),
-3.*sin(Physics::pi/6)+1.*cos(Physics::pi/6), 2., 1e-6);
}
}
\ No newline at end of file
......@@ -37,6 +37,8 @@
#include "Structure/BoundaryGeometry.h"
#include "AbsBeamline/SBend3D.h"
#include "opal_test_utilities/SilenceTest.h"
#include "Utilities/LogicalError.h"
class LoadFieldMap {
......@@ -140,6 +142,8 @@ class LoadFieldMap {
};
TEST(SBend3DTest, SBend3DGeometryTest) {
OpalTestUtilities::SilenceTest silencer;
LoadFieldMap fieldLoader("field1", 1, 1, -1);
SBend3D* field = fieldLoader.sbend3d_m;
if (field == NULL)
......@@ -205,6 +209,8 @@ void testField(double r, double y, double phi,
}
TEST(SBend3DTest, SBend3DFieldTest) {
OpalTestUtilities::SilenceTest silencer;
// 211.000000000 0.00000000000 0.00000000000 0.00000000000 0.00000000000
testField(0., 0., Physics::pi/8., 0., 5346.80707376*1e-4, 0., 1e-6);
// 211.000000000 0.250000000000 0.00000000000 71.6525328925 5351.82535885 -0.156196844700E-02
......@@ -213,22 +219,26 @@ TEST(SBend3DTest, SBend3DFieldTest) {
}
TEST(SBend3DTest, SBend3DBadFileTest) {
LoadFieldMap fieldLoader3("field5", 1, 1, -1); // should work okay
EXPECT_THROW(
LoadFieldMap fieldLoader3("field6", 1, 1, 3), // missing header line
LogicalError
);
EXPECT_THROW(
LoadFieldMap fieldLoader3("field7", 1, 1, 8), // missing first body
LogicalError
);
EXPECT_THROW(
LoadFieldMap fieldLoader3("field8", 1, 1, 34), // missing last body
LogicalError
);
OpalTestUtilities::SilenceTest silencer;
LoadFieldMap fieldLoader3("field5", 1, 1, -1); // should work okay
EXPECT_THROW(
LoadFieldMap fieldLoader3("field6", 1, 1, 3), // missing header line
LogicalError
);
EXPECT_THROW(
LoadFieldMap fieldLoader3("field7", 1, 1, 8), // missing first body
LogicalError
);
EXPECT_THROW(
LoadFieldMap fieldLoader3("field8", 1, 1, 34), // missing last body
LogicalError
);
}
TEST(SBend3DTest, SBend3DPolyPatchTest) {
OpalTestUtilities::SilenceTest silencer;
// make the poly order > 1; this puts SBend3D in PolynomialPatch mode;
// check the field map loads correctly including e.g. dipole symmetry
try {
......@@ -256,4 +266,4 @@ TEST(SBend3DTest, SBend3DPolyPatchTest) {
} catch (std::exception& err) {
std::cerr << err.what() << std::endl;
}
}
}
\ No newline at end of file
......@@ -34,6 +34,8 @@
#include "Algorithms/AbstractTimeDependence.h"
#include "Algorithms/PolynomialTimeDependence.h"
#include "opal_test_utilities/SilenceTest.h"
void testNull(VariableRFCavity& cav1) {
std::shared_ptr<AbstractTimeDependence> null_poly(NULL);
EXPECT_DOUBLE_EQ(cav1.getLength(), 0.);
......@@ -43,6 +45,8 @@ void testNull(VariableRFCavity& cav1) {
}
TEST(VariableRFCavityTest, TestConstructorEtc) {
OpalTestUtilities::SilenceTest silencer;
VariableRFCavity cav1;
EXPECT_EQ(cav1.getName(), "");
testNull(cav1);
......@@ -71,6 +75,8 @@ void testGetSet(VariableRFCavity& cav1,
}
TEST(VariableRFCavityTest, TestGetSet) {
OpalTestUtilities::SilenceTest silencer;
VariableRFCavity cav1;
testGetSet(cav1,
&VariableRFCavity::getAmplitudeModel,
......@@ -87,6 +93,8 @@ TEST(VariableRFCavityTest, TestGetSet) {
}
TEST(VariableRFCavityTest, TestAssignmentNull) {
OpalTestUtilities::SilenceTest silencer;
VariableRFCavity cav1;
VariableRFCavity cav2;
cav2.getLength(); // stop compiler "optimising" to copy constructor
......@@ -97,6 +105,8 @@ TEST(VariableRFCavityTest, TestAssignmentNull) {
}
TEST(VariableRFCavityTest, TestAssignmentValue) {
OpalTestUtilities::SilenceTest silencer;
std::shared_ptr<AbstractTimeDependence> poly1(new PolynomialTimeDependence(std::vector<double>(1, 1.)));
std::shared_ptr<AbstractTimeDependence> poly2(new PolynomialTimeDependence(std::vector<double>(1, 2.)));
std::shared_ptr<AbstractTimeDependence> poly3(new PolynomialTimeDependence(std::vector<double>(1, 3.)));
......@@ -116,6 +126,8 @@ TEST(VariableRFCavityTest, TestAssignmentValue) {
}
TEST(VariableRFCavityTest, TestClone) {
OpalTestUtilities::SilenceTest silencer;
VariableRFCavity cav1;
cav1.setLength(99.);
VariableRFCavity* cav2 = dynamic_cast<VariableRFCavity*>(cav1.clone());
......@@ -124,10 +136,14 @@ TEST(VariableRFCavityTest, TestClone) {
}
TEST(VariableRFCavityTest, TestInitialiseFinalise) {
OpalTestUtilities::SilenceTest silencer;
// nothing to do here
}
TEST(VariableRFCavityTest, TestGetGeometry) {
OpalTestUtilities::SilenceTest silencer;
VariableRFCavity cav1;
const VariableRFCavity& cav2(cav1);
EXPECT_EQ(&cav1.getGeometry(), &cav2.getGeometry());
......@@ -136,11 +152,15 @@ TEST(VariableRFCavityTest, TestGetGeometry) {
}
TEST(VariableRFCavityTest, TestBends) {
OpalTestUtilities::SilenceTest silencer;
VariableRFCavity cav1;
EXPECT_FALSE(cav1.bends());
}
TEST(VariableRFCavityTest, TestApplyField) {
OpalTestUtilities::SilenceTest silencer;
VariableRFCavity cav1;
std::vector<double> vec1;
vec1.push_back(1.);
......@@ -177,6 +197,8 @@ TEST(VariableRFCavityTest, TestApplyField) {
}
TEST(VariableRFCavityTest, TestApplyBoundingBox) {
OpalTestUtilities::SilenceTest silencer;
VariableRFCavity cav1;
std::shared_ptr<AbstractTimeDependence> poly1(new PolynomialTimeDependence(std::vector<double>(1, 1.)));
std::shared_ptr<AbstractTimeDependence> poly2(new PolynomialTimeDependence(std::vector<double>(2, 2.)));
......
......@@ -3,7 +3,11 @@
#include "Algorithms/AbstractTimeDependence.h"
#include "Algorithms/PolynomialTimeDependence.h"
#include "opal_test_utilities/SilenceTest.h"
TEST(PolynomialTimeDependenceTest, PolynomialTimeDependenceTest) {
OpalTestUtilities::SilenceTest silencer;
// Check empty polynomial coefficients always returns 0.
std::vector<double> test;
PolynomialTimeDependence time_dependence_1(test);
......@@ -27,6 +31,8 @@ TEST(PolynomialTimeDependenceTest, PolynomialTimeDependenceTest) {
}
TEST(PolynomialTimeDependenceTest, TDMapTest) {
OpalTestUtilities::SilenceTest silencer;
// throw on empty value
EXPECT_THROW(AbstractTimeDependence::getTimeDependence("name"),
GeneralClassicException);
......@@ -49,6 +55,8 @@ TEST(PolynomialTimeDependenceTest, TDMapTest) {
}
TEST(PolynomialTimeDependenceTest, TDMapNameLookupTest) {
OpalTestUtilities::SilenceTest silencer;
EXPECT_THROW(AbstractTimeDependence::getName(NULL),
GeneralClassicException);
PolynomialTimeDependence time_dep(std::vector<double>(1, 1));
......@@ -65,4 +73,4 @@ TEST(PolynomialTimeDependenceTest, TDMapNameLookupTest) {
EXPECT_THROW(AbstractTimeDependence::getName(td3),
GeneralClassicException);
}
}
\ No newline at end of file
/*
/*
* Copyright (c) 2015, Chris Rogers
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STFC nor the names of its contributors may be used to
* endorse or promote products derived from this software without specific
* 3. Neither the name of STFC nor the names of its contributors may be used to
* endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
......@@ -41,6 +41,8 @@
#include "Fields/Interpolation/PolynomialCoefficient.h"
#include "Fields/Interpolation/PPSolveFactory.h"
#include "opal_test_utilities/SilenceTest.h"
using namespace interpolation;
void test_points(int dim, int lower, int upper, std::vector< std::vector<int> > pts) {
......@@ -78,6 +80,8 @@ void test_points(int dim, int lower, int upper, std::vector< std::vector<int> >
}
TEST(PPSolveFactoryTest, TestNearbyPointsSquares) {
OpalTestUtilities::SilenceTest silencer;
for (int upper = 0; upper < 5; ++upper) {
for (int lower = 0; lower < upper; ++lower) {
for (int dim = 1; dim < 5; ++dim) {
......@@ -160,7 +164,7 @@ TEST_F(PPSolveFactoryTestFixture, TestSolvePolynomialQuadratic) {
<< "col " << i << " row " << j;
}
// now check that the values in each polynomial are correct
// now check that the values in each polynomial are correct
ThreeDGrid testGrid(1./4., 2./4., 3./4., -1., -2., -3., np*4-1, np*4-1, np*4-1);
for (Mesh::Iterator it = testGrid.begin(); it < testGrid.end(); ++it) {
std::vector<double> refValue(2);
......@@ -199,7 +203,7 @@ TEST_F(PPSolveFactoryTestFixture, TestSolvePolynomialQuadraticSmoothed) {
<< "col " << i << " row " << j;
}
// now check that the values in each polynomial are correct
// now check that the values in each polynomial are correct
ThreeDGrid testGrid(1./4., 2./4., 3./4., -1., -2., -3., np*4-1, np*4-1, np*4-1);
for (Mesh::Iterator it = testGrid.begin(); it < testGrid.end(); ++it) {
std::vector<double> refValue(2);
......@@ -308,6 +312,8 @@ void plot(int n_points, std::vector<double> start, std::vector<double> end, Poly
TEST(PPSolveFactoryTest, TestThreeDSolveSinCos) {
OpalTestUtilities::SilenceTest silencer;
int np = 11;
ThreeDGrid grid(1., 1., 1., 1., 2., 3., np, np, np);
// test grid starts a few points in to avoid boundary effects
......@@ -360,7 +366,7 @@ TEST(PPSolveFactoryTest, TestThreeDSolveSinCos) {
prevTestValue = testValue;
}
}
for (size_t i = 0; i < sumError.size(); ++i) {
std::cout << i << ": ";
for (size_t j = 0; j < sumError[i].size(); ++j) {
......@@ -374,6 +380,4 @@ TEST(PPSolveFactoryTest, TestThreeDSolveSinCos) {
}
std::cout << std::endl;
}
}
}
\ No newline at end of file
/*
/*
* Copyright (c) 2015, Chris Rogers
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STFC nor the names of its contributors may be used to
* endorse or promote products derived from this software without specific
* 3. Neither the name of STFC nor the names of its contributors may be used to
* endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
......@@ -29,15 +29,19 @@
#include "Fields/Interpolation/PolynomialPatch.h"
#include "opal_test_utilities/SilenceTest.h"
using namespace interpolation;
TEST(PolynomialPatchTest, TestPolynomialPatch) {
OpalTestUtilities::SilenceTest silencer;
ThreeDGrid grid(1, 2, 3, -1, -2, -3, 4, 3, 2);
// we make a reference poly vector
std::vector<double> data(54);
for (size_t i = 0; i < data.size(); ++i)
data[i] = i/10.;
MMatrix<double> refCoeffs(2, 27, &data[0]);
MMatrix<double> refCoeffs(2, 27, &data[0]);
SquarePolynomialVector ref(3, refCoeffs);
// copy it into the grid
std::vector<SquarePolynomialVector*> poly;
......@@ -58,6 +62,4 @@ TEST(PolynomialPatchTest, TestPolynomialPatch) {
for (size_t i = 0; i < 2; ++i)
EXPECT_NEAR(testValue[i], refValue[i], 1e-6);
}
}
}
\ No newline at end of file
/*
/*
* Copyright (c) 2015, Chris Rogers
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STFC nor the names of its contributors may be used to
* endorse or promote products derived from this software without specific
* 3. Neither the name of STFC nor the names of its contributors may be used to
* endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
......@@ -31,14 +31,18 @@
#include "Fields/Interpolation/SquarePolynomialVector.h"
#include "Fields/Interpolation/MMatrix.h"
#include "opal_test_utilities/SilenceTest.h"
using namespace interpolation;
TEST(SolveFactoryTest, TestSolveNoDerivs) {
OpalTestUtilities::SilenceTest silencer;
// we make a reference poly vector
std::vector<double> data(27);
for (size_t i = 0; i < data.size(); ++i)
data[i] = i;
MMatrix<double> refCoeffs(3, 9, &data[0]);
MMatrix<double> refCoeffs(3, 9, &data[0]);
SquarePolynomialVector ref(2, refCoeffs);
// Make a set of points
std::vector< std::vector<double> > positions;
......@@ -64,7 +68,4 @@ TEST(SolveFactoryTest, TestSolveNoDerivs) {
for (size_t i = 0; i < 3; ++i)
for (size_t j = 0; j < 3; ++j)
EXPECT_NEAR(testCoeffs(i+1, j+1), refCoeffs(i+1, j+1), 1e-6);
}
}
\ No newline at end of file
/*
/*
* Copyright (c) 2015, Chris Rogers
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STFC nor the names of its contributors may be used to
* endorse or promote products derived from this software without specific
* 3. Neither the name of STFC nor the names of its contributors may be used to
* endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
......@@ -30,9 +30,13 @@
#include "Fields/Interpolation/SquarePolynomialVector.h"
#include "Fields/Interpolation/PolynomialCoefficient.h"
#include "opal_test_utilities/SilenceTest.h"
using namespace interpolation;
TEST(SquarePolynomialVectorTest, TestConstructorDestructor) {
OpalTestUtilities::SilenceTest silencer;
SquarePolynomialVector test1;
EXPECT_EQ(test1.PointDimension(), 0);
EXPECT_EQ(test1.ValueDimension(), 0);
......@@ -42,7 +46,7 @@ TEST(SquarePolynomialVectorTest, TestConstructorDestructor) {
std::vector<double> data(18);
for (size_t i = 0; i < data.size(); ++i)
data[i] = i;
MMatrix<double> refCoeffs(2, 9, &data[0]); // 2x9 -> c, x, y, xy, xx, xxy, xxyy, xyy, yy,
MMatrix<double> refCoeffs(2, 9, &data[0]); // 2x9 -> c, x, y, xy, xx, xxy, xxyy, xyy, yy,
SquarePolynomialVector test2(2, refCoeffs);
MMatrix<double> testCoeffs = test2.GetCoefficientsAsMatrix();
ASSERT_EQ(testCoeffs.num_row(), 2);
......@@ -55,8 +59,10 @@ TEST(SquarePolynomialVectorTest, TestConstructorDestructor) {
}
TEST(SquarePolynomialVectorTest, TestMakePolyVector) {
OpalTestUtilities::SilenceTest silencer;
std::vector<double> data(18, 0.);
MMatrix<double> refCoeffs(2, 9, &data[0]);
MMatrix<double> refCoeffs(2, 9, &data[0]);
SquarePolynomialVector ref(2, refCoeffs);
MVector<double> point(2, 0.);
MVector<double> polyVector(9, -99);
......@@ -74,10 +80,12 @@ TEST(SquarePolynomialVectorTest, TestMakePolyVector) {
}
TEST(SquarePolynomialVectorTest, TestF) {
OpalTestUtilities::SilenceTest silencer;
std::vector<double> data(18);
for (size_t i = 0; i < data.size(); ++i)
data[i] = i;
MMatrix<double> refCoeffs(2, 9, &data[0]);
MMatrix<double> refCoeffs(2, 9, &data[0]);
SquarePolynomialVector ref(2, refCoeffs);
std::vector<double> point1(2, 0.);
std::vector<double> value(2);
......@@ -100,7 +108,4 @@ TEST(SquarePolynomialVectorTest, TestF) {
ref.F(&point3[0], &value[0]);
EXPECT_EQ(value[0], refValue(1)); // sum (0, ..., 8)
EXPECT_EQ(value[1], refValue(2)); // sum (9, ..., 17)
}
}
\ No newline at end of file
/*
/*
* Copyright (c) 2015, Chris Rogers
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STFC nor the names of its contributors may be used to
* endorse or promote products derived from this software without specific
* 3. Neither the name of STFC nor the names of its contributors may be used to
* endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "gtest/gtest.h"
#include "Fields/Interpolation/ThreeDGrid.h"
#include "opal_test_utilities/SilenceTest.h"
using interpolation::ThreeDGrid;
namespace threegridtest {
TEST(ThreeDGridTest, LowerBoundTest) {
OpalTestUtilities::SilenceTest silencer;
std::vector<double> xVar(7), yVar(8), zVar(9);
for (size_t i = 0; i < xVar.size(); ++i) {
xVar[i] = 4.+1.*i;
......@@ -84,4 +88,4 @@ TEST(ThreeDGridTest, LowerBoundTest) {
}
}
}
}
}
\ No newline at end of file
......@@ -32,7 +32,11 @@
#include "Physics/Physics.h"
#include "Utilities/RingSection.h"
#include "opal_test_utilities/SilenceTest.h"
TEST(RingSectionTest, TestConstructDestruct) {
OpalTestUtilities::SilenceTest silencer;
RingSection ors;
MockComponent* compNull = NULL;
Vector_t vec0(0, 0, 0);
......@@ -52,6 +56,8 @@ TEST(RingSectionTest, TestConstructDestruct) {
}
TEST(RingSectionTest, TestIsOnOrPastStartPlane) {
OpalTestUtilities::SilenceTest silencer;
RingSection ors;
ors.setStartPosition(Vector_t(0., 1., 0.));
ors.setStartNormal(Vector_t(1., 0., 0.));
......@@ -91,6 +97,8 @@ TEST(RingSectionTest, TestIsOnOrPastStartPlane) {
}
TEST(RingSectionTest, TestIsPastEndPlane) {
OpalTestUtilities::SilenceTest silencer;
RingSection ors;
ors.setEndPosition(Vector_t(0., 1., 0.));
ors.setEndNormal(Vector_t(1., 0., 0.));
......@@ -129,6 +137,8 @@ TEST(RingSectionTest, TestIsPastEndPlane) {
}
TEST(RingSectionTest, TestGetFieldValue) {
OpalTestUtilities::SilenceTest silencer;
RingSection ors;
MockComponent comp;
ors.setComponent(&comp);
......@@ -167,6 +177,8 @@ bool sort_comparator(Vector_t v1, Vector_t v2) {
}
TEST(RingSectionTest, TestGetVirtualBoundingBox) {
OpalTestUtilities::SilenceTest silencer;
RingSection ors;
ors.setStartPosition(Vector_t(3, -1, 99));
ors.setStartNormal(Vector_t(-4, -1, -1000));
......@@ -201,6 +213,8 @@ RingSection buildORS(double r, double phi1, double phi2) {
}
TEST(RingSectionTest, TestDoesOverlap) {
OpalTestUtilities::SilenceTest silencer;
double f1 = 1.0*Physics::pi/6.;
double f2 = 0.5*Physics::pi/6.;
double f3 = -0.5*Physics::pi/6.;
......@@ -215,5 +229,4 @@ TEST(RingSectionTest, TestDoesOverlap) {
EXPECT_TRUE(ors3.doesOverlap(f2, f3));
EXPECT_FALSE(ors3.doesOverlap(f1, f1));
EXPECT_FALSE(ors3.doesOverlap(f4, f4));
}
}
\ No newline at end of file
......@@ -5,6 +5,8 @@
#include "Algorithms/StatisticalErrors.h"
#include "Structure/OpalInputInterpreter.h"
#include "opal_test_utilities/SilenceTest.h"
#include <iostream>
#include <fstream>
#include <string>
......@@ -13,6 +15,8 @@
TEST(StatisticalErrorTests, CPPCommentTest) {
OpalTestUtilities::SilenceTest silencer;
std::istringstream in(inputCPPCommentTest);
OpalInputInterpreter interpreter;
......@@ -29,6 +33,8 @@ TEST(StatisticalErrorTests, CPPCommentTest) {
TEST(StatisticalErrorTests, CCommentTest) {
OpalTestUtilities::SilenceTest silencer;
std::istringstream in(inputCCommentTest);
OpalInputInterpreter interpreter;
......@@ -44,6 +50,8 @@ TEST(StatisticalErrorTests, CCommentTest) {
}
TEST(StatisticalErrorTests, TGaussTest) {
OpalTestUtilities::SilenceTest silencer;
std::istringstream in(inputTGaussTest);
OpalInputInterpreter interpreter;
......@@ -72,6 +80,8 @@ TEST(StatisticalErrorTests, TGaussTest) {
}
TEST(StatisticalErrorTests, GaussTest) {
OpalTestUtilities::SilenceTest silencer;
std::istringstream in(inputGaussTest);
OpalInputInterpreter interpreter;
......@@ -114,6 +124,8 @@ TEST(StatisticalErrorTests, GaussTest) {
}
TEST(StatisticalErrorTests, CallTest) {
OpalTestUtilities::SilenceTest silencer;
std::istringstream in(inputCallTest);
OpalInputInterpreter interpreter;
......@@ -139,6 +151,8 @@ TEST(StatisticalErrorTests, CallTest) {
}
TEST(StatisticalErrorTests, FileTest) {
OpalTestUtilities::SilenceTest silencer;
std::ofstream ofh("FileTest.in");
ofh << inputGaussTest;
ofh.close();
......@@ -154,6 +168,8 @@ TEST(StatisticalErrorTests, FileTest) {
}
TEST(StatisticalErrorTests, SubFileTest) {
OpalTestUtilities::SilenceTest silencer;
std::ofstream ofh("FileTest.in");
ofh << inputSubFileTest1;
ofh.close();
......@@ -179,6 +195,8 @@ TEST(StatisticalErrorTests, SubFileTest) {
}
TEST(StatisticalErrorTests, ASTTest) {
OpalTestUtilities::SilenceTest silencer;
std::ofstream ofh("FileTest.in");
ofh << inputSubFileTest1;
ofh.close();
......@@ -196,6 +214,8 @@ TEST(StatisticalErrorTests, ASTTest) {
}
TEST(StatisticalErrorTests, ReplaceTest) {
OpalTestUtilities::SilenceTest silencer;
std::ofstream ofh("FileTest.in");
ofh << inputSubFileTest1;
ofh.close();
......
......@@ -36,6 +36,8 @@
#include "Utilities/OpalException.h"
#include "BasicActions/DumpEMFields.h"
#include "opal_test_utilities/SilenceTest.h"
namespace DumpEMFieldsTest {
void setOneAttribute(DumpEMFields* dump, std::string name, double value) {
......@@ -64,6 +66,8 @@ void setAttributes(DumpEMFields* dump,
}
TEST(DumpEMFieldsTest, ConstructorDestructor) {
OpalTestUtilities::SilenceTest silencer;
// neither in the set and grid is null
DumpEMFields* dump1 = new DumpEMFields();
delete dump1;
......@@ -84,6 +88,8 @@ void execute_throws(DumpEMFields* dump, std::string reason) {
}
TEST(DumpEMFieldsTest, executeTest) {
OpalTestUtilities::SilenceTest silencer;
// dump the fields
DumpEMFields dump1;
execute_throws(&dump1, "should throw due to nsteps < 1");
......@@ -114,6 +120,8 @@ void clear_files() {
}
TEST(DumpEMFieldsTest, writeFieldsTest) {
OpalTestUtilities::SilenceTest silencer;
clear_files();
DumpEMFields dump1;
setAttributes(&dump1, 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., "test1");
......@@ -176,5 +184,4 @@ TEST(DumpEMFieldsTest, writeFieldsTest) {
clear_files();
}
}
}
\ No newline at end of file
......@@ -35,6 +35,8 @@
#include "Utilities/OpalException.h"
#include "BasicActions/DumpFields.h"
#include "opal_test_utilities/SilenceTest.h"
namespace test {
void test() {}
......@@ -61,6 +63,8 @@ void setAttributes(DumpFields* dump,
}
TEST(DumpFieldsTest, ConstructorDestructor) {
OpalTestUtilities::SilenceTest silencer;
// neither in the set and grid is null
DumpFields* dump1 = new DumpFields();
delete dump1;
......@@ -81,6 +85,8 @@ void execute_throws(DumpFields* dump, std::string reason) {
}
TEST(DumpFieldsTest, executeTest) {
OpalTestUtilities::SilenceTest silencer;
// dump the fields
DumpFields dump1;
execute_throws(&dump1, "should throw due to nsteps < 1");
......@@ -109,6 +115,8 @@ void clear_files() {
}
TEST(DumpFieldsTest, writeFieldsTest) {
OpalTestUtilities::SilenceTest silencer;
clear_files();
DumpFields dump1;
setAttributes(&dump1, 1., 1., 1., 1., 1., 1., 1., 1., 1., "test1");
......@@ -167,5 +175,4 @@ TEST(DumpFieldsTest, writeFieldsTest) {
clear_files();
}
}
}
\ No newline at end of file
......@@ -9,7 +9,7 @@
#include "gsl/gsl_statistics_double.h"
TEST(BinomialTest, FullSigmaTest1) {
OpalTestUtilities::SilenceTest silencer(true);
OpalTestUtilities::SilenceTest silencer;
const double expectedR11 = 1.978;
const double expectedR22 = 0.7998;
......@@ -94,7 +94,7 @@ TEST(BinomialTest, FullSigmaTest1) {
}
TEST(BinomialTest, FullSigmaTest2) {
OpalTestUtilities::SilenceTest silencer(true);
OpalTestUtilities::SilenceTest silencer;
const double expectedR11 = 1.978;
const double expectedR22 = 0.7998;
......
......@@ -9,7 +9,7 @@
#include "gsl/gsl_statistics_double.h"
TEST(GaussTest, FullSigmaTest1) {
OpalTestUtilities::SilenceTest silencer(true);
OpalTestUtilities::SilenceTest silencer;
const double expectedR11 = 1.978;
const double expectedR22 = 0.7998;
......@@ -92,7 +92,7 @@ TEST(GaussTest, FullSigmaTest1) {
}
TEST(GaussTest, FullSigmaTest2) {
OpalTestUtilities::SilenceTest silencer(true);
OpalTestUtilities::SilenceTest silencer;
const double expectedR11 = 1.978;
const double expectedR22 = 0.7998;
......
......@@ -3,6 +3,8 @@
#include "gtest/gtest.h"
#include "Elements/OpalPolynomialTimeDependence.h"
#include "opal_test_utilities/SilenceTest.h"
class BeamlineVisitor;
// some comment
class TestElement : public ElementBase {
......@@ -28,12 +30,16 @@ class TestElement : public ElementBase {
};
TEST(OpalPolynomialTimeDependenceTest, ConstructorTest) {
OpalTestUtilities::SilenceTest silencer;
OpalPolynomialTimeDependence dep;
OpalPolynomialTimeDependence* dep_clone = dep.clone("new name");
EXPECT_EQ(dep_clone->getOpalName(), "new name");
}
TEST(OpalPolynomialTimeDependenceTest, PrintTest) {
OpalTestUtilities::SilenceTest silencer;
OpalPolynomialTimeDependence dep;
std::stringstream _string;
dep.print(_string);
......@@ -41,6 +47,8 @@ TEST(OpalPolynomialTimeDependenceTest, PrintTest) {
}
TEST(OpalPolynomialTimeDependenceTest, UpdateTest) {
OpalTestUtilities::SilenceTest silencer;
// std::cerr << "HELLO" << std::endl;
TestElement element;
// std::cerr << "WORLD" << std::endl;
......@@ -52,4 +60,4 @@ TEST(OpalPolynomialTimeDependenceTest, UpdateTest) {
// dependence.fillRegisteredAttributes(element, OpalElement::IDEAL_FLAG);
// std::cerr << "DONE" << std::endl;
}
}
\ No newline at end of file
/*
/*
* Copyright (c) 2014, Chris Rogers
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STFC nor the names of its contributors may be used to
* endorse or promote products derived from this software without specific
* 3. Neither the name of STFC nor the names of its contributors may be used to
* endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
......@@ -34,7 +34,11 @@
#include "Elements/OpalVariableRFCavity.h"
#include "BeamlineCore/DriftRep.h"
#include "opal_test_utilities/SilenceTest.h"
TEST(OpalVariableRFCavityTest, TestConstructorDestructor) {
OpalTestUtilities::SilenceTest silencer;
OpalVariableRFCavity cav1;
EXPECT_EQ((&cav1)->getOpalName(), "VARIABLE_RF_CAVITY");
OpalVariableRFCavity cav2("name", &cav1);
......@@ -43,12 +47,14 @@ TEST(OpalVariableRFCavityTest, TestConstructorDestructor) {
EXPECT_EQ(cav3->getOpalName(), "name");
OpalVariableRFCavity* cav4 = cav2.clone("other_name");
EXPECT_EQ(cav4->getOpalName(), "other_name");
delete cav4;
delete cav3;
}
TEST(OpalVariableRFCavityTest, TestFillRegisteredAttributes) {
OpalTestUtilities::SilenceTest silencer;
/*
PolynomialTimeDependence* pd1 = new PolynomialTimeDependence();
PolynomialTimeDependence* pd2 = new PolynomialTimeDependence();
......@@ -92,6 +98,7 @@ TEST(OpalVariableRFCavityTest, TestFillRegisteredAttributes) {
}
TEST(OpalVariableRFCavityTest, TestUpdate) {
// EXPECT_TRUE(false);
}
OpalTestUtilities::SilenceTest silencer;
// EXPECT_TRUE(false);
}
\ No newline at end of file
......@@ -3,9 +3,9 @@
std::streambuf *OpalTestUtilities::SilenceTest::_defaultCout = NULL;
std::streambuf *OpalTestUtilities::SilenceTest::_defaultCerr = NULL;
OpalTestUtilities::SilenceTest::SilenceTest(bool willSilence):
OpalTestUtilities::SilenceTest::SilenceTest():
_failed(false) {
if (willSilence && _defaultCout == NULL ) {
if (_defaultCout == NULL ) {
_defaultCout = std::cout.rdbuf();
_defaultCerr = std::cerr.rdbuf();
......
......@@ -41,12 +41,11 @@ namespace OpalTestUtilities {
class SilenceTest {
public:
SilenceTest(bool willSilence);
SilenceTest();
~SilenceTest();
void setFailed();
private:
SilenceTest(); // disable default ctor
SilenceTest(const SilenceTest& test); // disable default copy ctor
std::ostringstream _debugOutput;
......
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