Skip to content

Commit

Permalink
move relative difference test to TestSuite` module
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Voigt authored and Alexander Voigt committed Jul 13, 2016
1 parent c6b928b commit 0da15b9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
14 changes: 14 additions & 0 deletions meta/TestSuite.m
Expand Up @@ -2,6 +2,7 @@
BeginPackage["TestSuite`"];

TestEquality::usage="tests equality of two expressions";
TestCloseRel::usage="tests relative numerical difference."
TestNonEquality::usage="tests inequality of two expressions";
TestCPPCode::usage="tests a C/C++ code snippet for an expected
result";
Expand Down Expand Up @@ -82,6 +83,19 @@
Return[{output, code}];
];

TestCloseRel[a_?NumericQ, b_?NumericQ, rel_?NumericQ] :=
If[Abs[a] < rel,
TestEquality[Abs[a - b] < rel, True],
TestEquality[Abs[(a - b)/a] < rel, True]
];

TestCloseRel[a_List, b_List, rel_?NumericQ] :=
MapThread[TestCloseRel[#1,#2,rel]&, {Flatten[a], Flatten[b]}];

TestCloseRel[a___] := (
Print["FAIL: ", {a}];
TestEquality[0,1]);

End[];

EndPackage[];
13 changes: 0 additions & 13 deletions test/test_CMSSM_librarylink.m
Expand Up @@ -99,19 +99,6 @@

delta = 1*^-8;

TestCloseRel[a_?NumericQ, b_?NumericQ, rel_?NumericQ] :=
If[Abs[a] < rel,
TestEquality[Abs[a - b] < rel, True],
TestEquality[Abs[(a - b)/a] < rel, True]
];

TestCloseRel[a_List, b_List, rel_?NumericQ] :=
MapThread[TestCloseRel[#1,#2,rel]&, {Flatten[a], Flatten[b]}];

TestCloseRel[a___] := (
Print["FAIL: ", {a}];
TestEquality[0,1]);

TestCloseRel[g1 * Sqrt[5/3] /. slhaData, g1 /. specML, delta];
TestCloseRel[g2 /. slhaData, g2 /. specML, delta];
TestCloseRel[g3 /. slhaData, g3 /. specML, delta];
Expand Down

0 comments on commit 0da15b9

Please sign in to comment.