CTEST2(io, binary_io) { for(idx_t i=0; i < data->ntensors; ++i) { sptensor_t * const gold = data->tensors[i]; /* write to binary */ tt_write_binary(gold, TMP_FILE); /* now read it back */ sptensor_t * tt_bin = tt_read(TMP_FILE); /* now check for correctness */ ASSERT_EQUAL(gold->nnz, tt_bin->nnz); ASSERT_EQUAL(gold->nmodes, tt_bin->nmodes); for(idx_t m=0; m < tt_bin->nmodes; ++m) { idx_t const * const gold_ind = gold->ind[m]; idx_t const * const test_ind = tt_bin->ind[m]; for(idx_t n=0; n < tt_bin->nnz; ++n) { ASSERT_EQUAL(gold_ind[n], test_ind[n]); } } /* values better be exact! */ val_t const * const gold_vals = gold->vals; val_t const * const test_vals = tt_bin->vals; for(idx_t n=0; n < tt_bin->nnz; ++n) { ASSERT_DBL_NEAR_TOL(gold_vals[n], test_vals[n], 0.); } } /* delete temporary file */ remove(TMP_FILE); }
CTEST(amax, samax){ blasint N=3, inc=1; float te_max=0.0, tr_max=0.0; float x[]={-1.1, 2.2, -3.3}; te_max=BLASFUNC(samax)(&N, x, &inc); tr_max=3.3; ASSERT_DBL_NEAR_TOL((double)(tr_max), (double)(te_max), SINGLE_EPS); }
CTEST(ctest, test_dbl_near_tol) { double a = 0.000111; ASSERT_DBL_NEAR_TOL(0.0001, a, 1e-5); /* will fail */ }