cloudy  trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TestFpCheck.cpp
Go to the documentation of this file.
1 /* This file is part of Cloudy and is copyright (C)1978-2022 by Gary J. Ferland and
2  * others. For conditions of distribution and use see copyright notice in license.txt */
3 #include "cdstd.h"
4 #include <UnitTest++.h>
5 #include "cddefines.h"
6 
7 namespace {
8  TEST(FpBoundRealnumOK)
9  {
10  realnum lo=1.,hi=2.,x=1.5;
11  CHECK(fp_bound(lo,x,hi));
12  }
13  TEST(FpBoundRealnumFail)
14  {
15  realnum lo=1.,hi=2.,x=2.5;
16  CHECK(!fp_bound(lo,x,hi));
17  }
18  TEST(FpBoundDoubleOK)
19  {
20  double lo=1.,hi=2.,x=1.5;
21  CHECK(fp_bound(lo,x,hi));
22  }
23  TEST(FpBoundDoubleFail)
24  {
25  double lo=1.,hi=2.,x=2.5;
26  CHECK(!fp_bound(lo,x,hi));
27  }
28  TEST(FpBoundRealnumTolOK)
29  {
30  realnum lo=1.,hi=2.,x=1.5;
31  CHECK(fp_bound_tol(lo,x,hi,(realnum)1.0e-3));
32  }
33  TEST(FpBoundRealnumTolFail)
34  {
35  realnum lo=1.,hi=2.,x=2.5;
36  CHECK(!fp_bound_tol(lo,x,hi,(realnum)1.0e-3));
37  }
38  TEST(FpBoundRealnumTolWide)
39  {
40  realnum lo=1.,hi=2.,x=2.5;
41  CHECK(fp_bound_tol(lo,x,hi,(realnum)1.0));
42  }
43  TEST(FpBoundDoubleTolOK)
44  {
45  double lo=1.,hi=2.,x=1.5;
46  CHECK(fp_bound_tol(lo,x,hi,1e-3));
47  }
48  TEST(FpBoundDoubleTolFail)
49  {
50  double lo=1.,hi=2.,x=2.5;
51  CHECK(!fp_bound_tol(lo,x,hi,1e-3));
52  }
53  TEST(FpBoundDoubleTolWide)
54  {
55  double lo=1.,hi=2.,x=2.5;
56  CHECK(fp_bound_tol(lo,x,hi,1.0));
57  }
58 }
bool fp_bound_tol(sys_float lo, sys_float x, sys_float hi, sys_float tol)
Definition: cddefines.h:951
float realnum
Definition: cddefines.h:124
bool fp_bound(sys_float lo, sys_float x, sys_float hi, int n=3)
Definition: cddefines.h:927