File: test_float.cxx

package info (click to toggle)
libpqxx 4.0.1%2Bdfsg3-8
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 16,012 kB
  • ctags: 9,469
  • sloc: sh: 11,289; cpp: 10,801; xml: 1,256; makefile: 287; ansic: 195; python: 159
file content (37 lines) | stat: -rw-r--r-- 746 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
#include <test_helpers.hxx>

using namespace PGSTD;
using namespace pqxx;

namespace
{
template<typename T> T make_infinity()
{
  return
#ifdef PQXX_HAVE_LIMITS
    numeric_limits<T>::infinity();
#else
    INFINITY;
#endif
}

void infinity_test(transaction_base &)
{
  double inf = make_infinity<double>();
  string inf_string;
  double back_conversion;

  inf_string = to_string(inf);
  from_string(inf_string, back_conversion);
  PQXX_CHECK_LESS(
	999999999,
	back_conversion,
	"Infinity doesn't convert back to something huge.");

  inf_string = to_string(-inf);
  from_string(inf_string, back_conversion);
  PQXX_CHECK_LESS(back_conversion, -999999999, "Negative infinity is broken");
}
} // namespace

PQXX_REGISTER_TEST_NODB(infinity_test)