END_TEST START_TEST (test_util_isInf) { fail_unless( util_isInf( util_PosInf() ) == 1 ); fail_unless( util_isInf( util_NegInf() ) == -1 ); fail_unless( util_isInf( util_NaN() ) == 0 ); fail_unless( util_isInf( util_NegZero() ) == 0 ); fail_unless( util_isInf(0.0) == 0 ); fail_unless( util_isInf(1.2) == 0 ); }
END_TEST START_TEST (test_util_NegInf) { double d = util_NegInf(); if ( util_isFinite(d) || util_isNaN(d) || d >= 0) { fail("util_NegInf() did not return -Inf."); } }
END_TEST START_TEST (test_FormulaFormatter_formatReal) { StringBuffer_t *sb = StringBuffer_create(42); char *s = StringBuffer_getBuffer(sb); ASTNode_t *n = ASTNode_create(); /** 1.2 **/ ASTNode_setReal(n, 1.2); FormulaFormatter_formatReal(sb, n); fail_unless( !strcmp(s, "1.2"), NULL ); StringBuffer_reset(sb); /** 1e-100 **/ ASTNode_setRealWithExponent(n, 1, -100); FormulaFormatter_formatReal(sb, n); fail_unless( !strcmp(s, "1.000000e-100"), NULL ); StringBuffer_reset(sb); /** NaN **/ ASTNode_setReal(n, util_NaN()); FormulaFormatter_formatReal(sb, n); fail_unless( !strcmp(s, "NaN"), NULL ); StringBuffer_reset(sb); /** Inf **/ ASTNode_setReal(n, util_PosInf()); FormulaFormatter_formatReal(sb, n); fail_unless( !strcmp(s, "INF"), NULL ); StringBuffer_reset(sb); /** -Inf **/ ASTNode_setReal(n, util_NegInf()); FormulaFormatter_formatReal(sb, n); fail_unless( !strcmp(s, "-INF"), NULL ); StringBuffer_reset(sb); /** -0 **/ ASTNode_setReal(n, util_NegZero()); FormulaFormatter_formatReal(sb, n); fail_unless( !strcmp(s, "-0"), NULL ); StringBuffer_reset(sb); StringBuffer_free(sb); ASTNode_free(n); }