Commit 16ea7c75 authored by Peter Eastman's avatar Peter Eastman
Browse files

Test cases which may occasionally fail say so in the error message.

parent 172f8759
...@@ -121,7 +121,7 @@ void testTemperature() { ...@@ -121,7 +121,7 @@ void testTemperature() {
} }
pe /= steps; pe /= steps;
double expected = 0.5*numBonds*BOLTZ*temp; double expected = 0.5*numBonds*BOLTZ*temp;
ASSERT_EQUAL_TOL(expected, pe, 0.1*expected); ASSERT_USUALLY_EQUAL_TOL(expected, pe, 0.1*expected);
} }
void testConstraints() { void testConstraints() {
......
...@@ -126,7 +126,7 @@ void testTemperature() { ...@@ -126,7 +126,7 @@ void testTemperature() {
} }
ke /= 10000; ke /= 10000;
double expected = 0.5*numParticles*3*BOLTZ*temp; double expected = 0.5*numParticles*3*BOLTZ*temp;
ASSERT_EQUAL_TOL(expected, ke, 6/std::sqrt(10000.0)); ASSERT_USUALLY_EQUAL_TOL(expected, ke, 6/std::sqrt(10000.0));
} }
void testConstraints() { void testConstraints() {
......
...@@ -126,7 +126,7 @@ void testTemperature() { ...@@ -126,7 +126,7 @@ void testTemperature() {
} }
ke /= 1000; ke /= 1000;
double expected = 0.5*numParticles*3*BOLTZ*temp; double expected = 0.5*numParticles*3*BOLTZ*temp;
ASSERT_EQUAL_TOL(expected, ke, 3*expected/std::sqrt(1000.0)); ASSERT_USUALLY_EQUAL_TOL(expected, ke, 3*expected/std::sqrt(1000.0));
} }
void testConstraints() { void testConstraints() {
......
...@@ -121,7 +121,7 @@ void testTemperature() { ...@@ -121,7 +121,7 @@ void testTemperature() {
} }
pe /= steps; pe /= steps;
double expected = 0.5*numBonds*BOLTZ*temp; double expected = 0.5*numBonds*BOLTZ*temp;
ASSERT_EQUAL_TOL(expected, pe, 0.1*expected); ASSERT_USUALLY_EQUAL_TOL(expected, pe, 0.1*expected);
} }
void testConstraints() { void testConstraints() {
......
...@@ -126,7 +126,7 @@ void testTemperature() { ...@@ -126,7 +126,7 @@ void testTemperature() {
} }
ke /= 10000; ke /= 10000;
double expected = 0.5*numParticles*3*BOLTZ*temp; double expected = 0.5*numParticles*3*BOLTZ*temp;
ASSERT_EQUAL_TOL(expected, ke, 6/std::sqrt(10000.0)); ASSERT_USUALLY_EQUAL_TOL(expected, ke, 6/std::sqrt(10000.0));
} }
void testConstraints() { void testConstraints() {
......
...@@ -126,7 +126,7 @@ void testTemperature() { ...@@ -126,7 +126,7 @@ void testTemperature() {
} }
ke /= 1000; ke /= 1000;
double expected = 0.5*numParticles*3*BOLTZ*temp; double expected = 0.5*numParticles*3*BOLTZ*temp;
ASSERT_EQUAL_TOL(expected, ke, 3*expected/std::sqrt(1000.0)); ASSERT_USUALLY_EQUAL_TOL(expected, ke, 3*expected/std::sqrt(1000.0));
} }
void testConstraints() { void testConstraints() {
......
...@@ -119,7 +119,7 @@ void testTemperature() { ...@@ -119,7 +119,7 @@ void testTemperature() {
} }
pe /= steps; pe /= steps;
double expected = 0.5*numBonds*BOLTZ*temp; double expected = 0.5*numBonds*BOLTZ*temp;
ASSERT_EQUAL_TOL(expected, pe, 0.1*expected); ASSERT_USUALLY_EQUAL_TOL(expected, pe, 0.1*expected);
} }
void testConstraints() { void testConstraints() {
......
...@@ -126,7 +126,7 @@ void testTemperature() { ...@@ -126,7 +126,7 @@ void testTemperature() {
} }
ke /= 10000; ke /= 10000;
double expected = 0.5*numParticles*3*BOLTZ*temp; double expected = 0.5*numParticles*3*BOLTZ*temp;
ASSERT_EQUAL_TOL(expected, ke, 6/std::sqrt(10000.0)); ASSERT_USUALLY_EQUAL_TOL(expected, ke, 6/std::sqrt(10000.0));
} }
void testConstraints() { void testConstraints() {
......
...@@ -126,7 +126,7 @@ void testTemperature() { ...@@ -126,7 +126,7 @@ void testTemperature() {
} }
ke /= 1000; ke /= 1000;
double expected = 0.5*numParticles*3*BOLTZ*temp; double expected = 0.5*numParticles*3*BOLTZ*temp;
ASSERT_EQUAL_TOL(expected, ke, 3*expected/std::sqrt(1000.0)); ASSERT_USUALLY_EQUAL_TOL(expected, ke, 3*expected/std::sqrt(1000.0));
} }
void testConstraints() { void testConstraints() {
......
...@@ -62,4 +62,6 @@ void throwException(const char* file, int line, const std::string& details) { ...@@ -62,4 +62,6 @@ void throwException(const char* file, int line, const std::string& details) {
#define ASSERT_EQUAL_VEC(expected, found, tol) {ASSERT_EQUAL_TOL((expected)[0], (found)[0], (tol)); ASSERT_EQUAL_TOL((expected)[1], (found)[1], (tol)); ASSERT_EQUAL_TOL((expected)[2], (found)[2], (tol));}; #define ASSERT_EQUAL_VEC(expected, found, tol) {ASSERT_EQUAL_TOL((expected)[0], (found)[0], (tol)); ASSERT_EQUAL_TOL((expected)[1], (found)[1], (tol)); ASSERT_EQUAL_TOL((expected)[2], (found)[2], (tol));};
#define ASSERT_USUALLY_EQUAL_TOL(expected, found, tol) {double _scale_ = std::fabs(expected) > 1.0 ? std::fabs(expected) : 1.0; if (!(std::fabs((expected)-(found))/_scale_ <= (tol))) {std::stringstream details; details << "Expected "<<(expected)<<", found "<<(found)<<" (This test is stochastic and may occasionally fail)"; throwException(__FILE__, __LINE__, details.str());}};
#endif /*OPENMM_ASSERTIONUTILITIES_H_*/ #endif /*OPENMM_ASSERTIONUTILITIES_H_*/
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment