Skip to content

Commit

Permalink
Fix inconsistencies in tests
Browse files Browse the repository at this point in the history
* Delete unused macros
* Delete mostly unused types
* Split overly large tests
* Fix duplicate test names
  • Loading branch information
mfasi committed Jun 2, 2024
1 parent 9ae6e80 commit 15e22cf
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions test/cpfloat_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,15 @@ typedef union {
#define CONST_PI 3.14159265358979323846
#define CONST_SQRT2 1.41421356237309504880

#define MINFORMAT 0
#define MAXFORMAT 2
#define MINMODE -1
#define MAXMODE 8
#define NREPS 1000

/* Define default target formats. */
// binary16, bfloat16, TensorFloat-32
static size_t precision [] = {11, 8, 11};
static size_t emax [] = {15, 127, 127};
static size_t emin [] = {-14, -126, -126};
// binary16, bfloat16
static size_t precision [] = {11, 8};
static size_t emax [] = {15, 127};
static size_t emin [] = {-14, -126};
static size_t nformats = 2;

/* Structure for options and fixtures. */
Expand Down Expand Up @@ -324,7 +322,7 @@ void check_equality_double(double *x, double *y, size_t n) {
for (size_t j = 0; j < n; j++) {
if (!nan_safe_compare_double(x[j], y[j])) {
printf("DOUBLE\n");
printf("***\nj = %ld\nx = %23.15e [%" PRIu64 "]\ny = %23.15e [%" PRIu64 "]\n",
printf("***\nj = %ld\nx = %23.15e [%" PRIu64 "]\ny = %23.15e [%" PRIu64 "]\n",
j,
x[j], *(uint64_t *)(x + j),
y[j], *(uint64_t *)(y + j));
Expand All @@ -338,7 +336,7 @@ void check_equality_double_int(double *x, int *y, size_t n) {
for (size_t j = 0; j < n; j++) {
if (!nan_safe_compare_double(x[j], y[j])) {
printf("DOUBLE\n");
printf("***\nj = %ld\nx = %23.15e [%" PRIu64 "]\ny = %23.15e\n",
printf("***\nj = %ld\nx = %23.15e [%" PRIu64 "]\ny = %23.15e\n",
j, x[j], *(uint64_t *)(x + j), (double)y[j]);
}
ck_assert(nan_safe_compare_double(x[j], (double)y[j]));
Expand Down Expand Up @@ -916,15 +914,15 @@ for (size_t mode = 1; mode < 3; mode++) {
double *zd = alloc_init_array_double(xd, n);
double *yd = allocate_array_double(xd, n, mode);
select_tests_det_double(yd, xd, zd, n, fpopts,
MINMODE, MAXMODE, 0, 2, -1, -1);
MINMODE, MAXMODE, 0, nformats - 1, -1, -1);
free(zd);
free_array_double(yd, mode);

float xf [] = {0, -0, inf_float(), -inf_float(), nan_float()};
float *zf = alloc_init_array_float(xf, n);
float *yf = allocate_array_float(xf, n, mode);
select_tests_det_float(yf, xf, zf, n, fpopts,
MINMODE, MAXMODE, 0, 2, -1, -1);
MINMODE, MAXMODE, 0, nformats - 1, -1, -1);
free(zf);
free_array_float(yf, mode);
}
Expand Down Expand Up @@ -2624,11 +2622,10 @@ free(onef);
free(exp);
free(lexp);

#test enumeration_floating_point_numbers
printf("4c. Next and previous floating-point number\n");
#test floating_point_enumeration_subnormal_numbers
printf("4c. Next and previous floating-point number: subnormal numbers\n");
fpopts->explim = CPFLOAT_EXPRANGE_TARG;
fpopts->subnormal = CPFLOAT_SUBN_USE;
// Subnormals
for (size_t mode = 2; mode < 3; mode++) {
for (size_t i = 0; i < nformats; i++) {
fpopts->precision = precision[i];
Expand Down Expand Up @@ -2729,7 +2726,8 @@ for (size_t mode = 2; mode < 3; mode++) {
}
}

// Normals
#test floating_point_enumeration_normal_numbers
printf("4d. Next and previous floating-point number: normal numbers\n");
for (size_t mode = 2; mode < 3; mode++) {
for (size_t i = 0; i < nformats; i++) {
fpopts->precision = precision[i];
Expand Down Expand Up @@ -2839,12 +2837,10 @@ for (size_t mode = 2; mode < 3; mode++) {
}

#test integer_rounding
printf("4c. Integer rounding\n");

printf("4e. Integer rounding\n");
fpopts->emax = emax[1];
fpopts->emin = emin[1];
fpopts->precision = precision[1];

size_t n = 32;
double *xd = malloc(n * sizeof(*xd));
int *xi = malloc(n * sizeof(*xi));
Expand Down Expand Up @@ -3012,7 +3008,7 @@ check_equality_double_long_long(rd7, xll, n-3);


#test arithmetic_operations_large
printf("4d. Arithmetic operations on large arrays\n");
printf("4f. Arithmetic operations on large arrays\n");
size_t i = 0;
fpopts->precision = precision[i];
fpopts->emax = emax[i];
Expand Down

0 comments on commit 15e22cf

Please sign in to comment.