File: test_ceil.cpp

package info (click to toggle)
fplll 5.5.0-1.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,984 kB
  • sloc: cpp: 21,104; javascript: 1,284; sh: 1,050; makefile: 198; perl: 46; python: 42
file content (52 lines) | stat: -rw-r--r-- 876 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <fplll/fplll.h>

using namespace fplll;

template <class T> bool test_ceil()
{

  bool status = false;

  // Case 1: works with fixed values.
  FP_NR<T> value(3.5);
  FP_NR<T> ceiled{};
  ceiled.ceil(value);

  status |= (ceiled != 4);

  // Case 2: calling ceil either gives us a number >= value.
  value = rand();
  ceiled.ceil(value);
  status |= (ceiled < value);
  return status;
}

int main(int, char **)
{
  int status = 0;
  status += test_ceil<mpfr_t>();
  status += test_ceil<double>();
#ifdef FPLLL_WITH_LONG_DOUBLE
  status += test_ceil<long double>();
#endif

#ifdef FPLLL_WITH_QD
  status += test_ceil<dd_real>();
  status += test_ceil<qd_real>();
#endif

#ifdef FPLLL_WITH_DPE
  status += test_ceil<dpe_t>();
#endif

  if (status == 0)
  {
    std::cerr << "All tests passed" << std::endl;
    return 0;
  }
  else
  {
    return -1;
  }
  return 0;
}