From f781aa11ac959aa3a4cbb792e6583170143f7bff Mon Sep 17 00:00:00 2001 From: eschnett Date: Mon, 6 Feb 2012 16:59:05 +0000 Subject: Add tolerance to test cases git-svn-id: https://svn.cct.lsu.edu/repos/numrel/LSUThorns/Vectors/trunk@52 105869f7-3296-0410-a4ea-f4349344b45a --- src/test.cc | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/test.cc b/src/test.cc index 1dd3fd0..efd66ad 100644 --- a/src/test.cc +++ b/src/test.cc @@ -1,10 +1,15 @@ -#include "cctk.h" -#include "cctk_Arguments.h" -#include "cctk_Parameters.h" #include "vectors.h" -#include -#include +#include +#include +#include + +#include +#include +#include +#include + +using namespace std; inline int my_signbit (CCTK_REAL const x) { @@ -18,7 +23,9 @@ inline int my_signbit (CCTK_REAL const x) CCTK_VInfo (CCTK_THORNSTRING, "Test %s...", testname); \ CCTK_REAL res = (scalarexpr); \ CCTK_REAL vecres = (vecexpr); \ - if(vecres == res) \ + CCTK_REAL eps = numeric_limits::epsilon(); \ + assert(abs((CCTK_REAL)0.1) > 0); \ + if (abs(vecres - res) < 10*eps*abs(res)) \ passed++; \ else \ CCTK_VParamWarn(CCTK_THORNSTRING, \ @@ -35,7 +42,9 @@ inline int my_signbit (CCTK_REAL const x) for(int i=0; i::epsilon(); \ + assert(abs((CCTK_REAL)0.1) > 0); \ + if(abs(vecres - res) < 10*eps*abs(res)) \ passed++; \ else \ CCTK_VParamWarn(CCTK_THORNSTRING, \ @@ -153,7 +162,7 @@ void Vectors_Test(CCTK_ARGUMENTS) } } /* The partial stores are not implemented for d==0 and - d==CCTK_REAL_VEC_SIZE-1 (because these are trivial) */ + d==CCTK_REAL_VEC_SIZE (because these are trivial) */ for (int d=1; d