fp80_cvtd.c (9888:68d6b600d51f) | fp80_cvtd.c (9899:0392ef94d766) |
---|---|
1/* 2 * Copyright (c) 2013, Andreas Sandberg 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * --- 21 unchanged lines hidden (view full) --- 30#include <fputils/fp80.h> 31 32#include "test_helper.h" 33 34#include <math.h> 35#include <stdio.h> 36#include <stdlib.h> 37 | 1/* 2 * Copyright (c) 2013, Andreas Sandberg 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * --- 21 unchanged lines hidden (view full) --- 30#include <fputils/fp80.h> 31 32#include "test_helper.h" 33 34#include <math.h> 35#include <stdio.h> 36#include <stdlib.h> 37 |
38/* We provide our own version of isinf_sgn since the C99 standard 39 * doesn't guarantee that isinf() returns the sign of the infinity 40 * (most implementations do). */ 41static inline int 42isinf_sgn(double x) 43{ 44 return isinf(x) ? (signbit(x) ? -1 : 1) : 0; 45} 46 |
|
38static void 39test_fp80_cvtd_class(const char *name, fp80_t fin, int class) 40{ 41 double d = fp80_cvtd(fin); 42 if (fpclassify(d) != class) { 43 test_diag("wrong class"); 44 test_fail(name); 45 } else { 46 test_ok(name); 47 } 48} 49 50static void | 47static void 48test_fp80_cvtd_class(const char *name, fp80_t fin, int class) 49{ 50 double d = fp80_cvtd(fin); 51 if (fpclassify(d) != class) { 52 test_diag("wrong class"); 53 test_fail(name); 54 } else { 55 test_ok(name); 56 } 57} 58 59static void |
51test_fp80_cvtd_inf(const char *name, fp80_t fin, int inf_class) | 60test_fp80_cvtd_inf(const char *name, fp80_t fin, int expected_inf_class) |
52{ 53 double d = fp80_cvtd(fin); | 61{ 62 double d = fp80_cvtd(fin); |
54 if (isinf(d) != inf_class) { | 63 if (isinf_sgn(d) != expected_inf_class) { |
55 test_diag("wrong infinity type"); 56 test_fail(name); 57 } else { 58 test_ok(name); 59 } 60} 61 62int --- 13 unchanged lines hidden --- | 64 test_diag("wrong infinity type"); 65 test_fail(name); 66 } else { 67 test_ok(name); 68 } 69} 70 71int --- 13 unchanged lines hidden --- |