Пример #1
0
AssertionResult AssertPred1Helper(const char* pred_str, const char* expr1
                                  , PRED pred, T1 val1)
{
    if( (*pred)(val1) )
    {
        return AssertionSuccess();
    }
    return AssertionFailure() << "error: " << pred_str << "(" << expr1 << ") evaluates to false, where "
           << "\n" << expr1 << " : " << val1;
}
Пример #2
0
AssertionResult AssertPredVariadicHelper(const char* pred_str, const char* params
        , PRED pred, Args... args)
{
    if( (*pred)(args...) )
    {
        return AssertionSuccess();
    }
    return AssertionFailure() << "error: " << pred_str << "("
           << params << ") evaluates to false, where "
           << "\n" << PrintToStrings("\n", args...);
}
Пример #3
0
AssertionResult
Pred_SECFailure(const char* expectedExpr, const char* actualExpr,
                PRErrorCode expectedErrorCode, SECStatus actual)
{
  if (SECFailure == actual && expectedErrorCode == PR_GetError()) {
    return AssertionSuccess();
  }

  return AssertionFailure()
      << "Expected: (" << expectedExpr << ") == (" << actualExpr
      << "), actual: " << SECFailure << " != " << actual;
}
Пример #4
0
AssertionResult CmpHelperSTRCASENE(const char* s1_expression,
    const char* s2_expression,
    const char* s1,
    const char* s2) {
        if (!String::CaseInsensitiveCStringEquals(s1, s2)) {
            return AssertionSuccess();
        } else {
            return AssertionFailure()
                << "Expected: (" << s1_expression << ") != ("
                << s2_expression << ") (ignoring case), actual: \""
                << s1 << "\" vs \"" << s2 << "\"";
        }
}
Пример #5
0
AssertionResult CmpHelperSTREQ(const char* expected_expression,
    const char* actual_expression,
    const char* expected,
    const char* actual) {
        if (String::CStringEquals(expected, actual)) {
            return AssertionSuccess();
        }

        return EqFailure(expected_expression,
            actual_expression,
            impl::ShowCStringQuoted(expected),
            impl::ShowCStringQuoted(actual),
            false);
}
Пример #6
0
    AssertionResult CheckMPtr( BFProgram& app, size_t expected )
    {
        size_t actual = app.memoryPointerOffset();

        if ( expected == actual )
        {
            return AssertionSuccess();
        }
        else
        {
            return AssertionFailure()
                << "Memory pointer was: " << actual
                << ". Expected: "         << expected;
        }
    }
Пример #7
0
    AssertionResult CheckIPtr( BFProgram& app, size_t expected )
    {
        size_t actual = app.instructionOffset();

        if ( expected == actual )
        {
            return AssertionSuccess();
        }
        else
        {
            return AssertionFailure()
                << "Instruction pointer was: " << actual
                << ". Expected: "              << expected;
        }
    }
Пример #8
0
AssertionResult AssertPred3Helper(const char* pred_str
                                  , const char* expr1, const char* expr2, const char* expr3
                                  , PRED pred, T1 val1, T2 val2, T3 val3)
{
    if( (*pred)(val1, val2, val3) )
    {
        return AssertionSuccess();
    }
    return AssertionFailure() << "error: " << pred_str << "("
           << expr1 << ", " << expr2 << ", " << expr3
           << ") evaluates to false, where "
           << "\n" << expr1 << " : " << val1
           << "\n" << expr2 << " : " << val2
           << "\n" << expr3 << " : " << val3;
}
Пример #9
0
    AssertionResult CheckMem( BFProgram& app, size_t offset, BlockT expected )
    {
        BlockT actual = app.valueAt( offset );

        if ( actual == expected )
        {
            return AssertionSuccess();
        }
        else
        {
            return AssertionFailure()
                << "Value at memory address " << offset
                << "was: "   << actual        << ". "
                << "Expected: " << expected;
        }
    }
/**
* @brief Assertion that BIR binary expression @a expr has two operands, when
*        both are variables and first is named "arg1" and second is named "arg2".
*/
AssertionResult TestsWithLLVMValueConverter::areBinaryOperandsInCorrectOrder(
		ShPtr<BinaryOpExpr> expr) {
	auto firstOp = cast<Variable>(expr->getFirstOperand());
	if (!firstOp || firstOp->getName() != "arg1"s) {
		return AssertionFailure() << expr
			<< " does not have first operand arg1";
	}

	auto secondOp = cast<Variable>(expr->getSecondOperand());
	if (!secondOp || secondOp->getName() != "arg2"s) {
		return AssertionFailure() << expr
			<< " does not have first operand arg1";
	}

	return AssertionSuccess() << expr
		<< " has first operand arg1 and second operand arg2";
}
Пример #11
0
    AssertionResult assertMatNear(const char* expr1, const char* expr2, const char* eps_expr, InputArray m1_, InputArray m2_, double eps)
    {
        Mat m1 = getMat(m1_);
        Mat m2 = getMat(m2_);

        if (m1.size() != m2.size())
        {
            return AssertionFailure() << "Matrices \"" << expr1 << "\" and \"" << expr2 << "\" have different sizes : \""
                                      << expr1 << "\" [" << PrintToString(m1.size()) << "] vs \""
                                      << expr2 << "\" [" << PrintToString(m2.size()) << "]";
        }

        if (m1.type() != m2.type())
        {
            return AssertionFailure() << "Matrices \"" << expr1 << "\" and \"" << expr2 << "\" have different types : \""
                                      << expr1 << "\" [" << PrintToString(MatType(m1.type())) << "] vs \""
                                      << expr2 << "\" [" << PrintToString(MatType(m2.type())) << "]";
        }

        Mat diff;
        absdiff(m1.reshape(1), m2.reshape(1), diff);

        double maxVal = 0.0;
        Point maxLoc;
        minMaxLocGold(diff, 0, &maxVal, 0, &maxLoc);

        if (maxVal > eps)
        {
            return AssertionFailure() << "The max difference between matrices \"" << expr1 << "\" and \"" << expr2
                                      << "\" is " << maxVal << " at (" << maxLoc.y << ", " << maxLoc.x / m1.channels() << ")"
                                      << ", which exceeds \"" << eps_expr << "\", where \""
                                      << expr1 << "\" at (" << maxLoc.y << ", " << maxLoc.x / m1.channels() << ") evaluates to " << printMatVal(m1, maxLoc) << ", \""
                                      << expr2 << "\" at (" << maxLoc.y << ", " << maxLoc.x / m1.channels() << ") evaluates to " << printMatVal(m2, maxLoc) << ", \""
                                      << eps_expr << "\" evaluates to " << eps;
        }

        return AssertionSuccess();
    }
/**
* @brief Assertion that BIR ternary expression @a expr has all operands in
*        correct order.
*
* All operands have to be variables, condition operand have to be named "cond",
* true value have to be named "true" and false value have to be named "false".
*/
AssertionResult TestsWithLLVMValueConverter::areTernaryOperandsInCorrectOrder(
		ShPtr<TernaryOpExpr> expr) {
	auto cond = cast<Variable>(expr->getCondition());
	if (!cond || cond->getName() != "cond"s) {
		return AssertionFailure() << expr
			<< " does not have condition as variable cond";
	}

	auto trueVal = cast<Variable>(expr->getTrueValue());
	if (!trueVal || trueVal->getName() != "true"s) {
		return AssertionFailure() << expr
			<< " does not have true value as variable true";
	}

	auto falseVal = cast<Variable>(expr->getFalseValue());
	if (!falseVal || falseVal->getName() != "false"s) {
		return AssertionFailure() << expr
			<< " does not have false value as variable false";
	}

	return AssertionSuccess() << expr
		<< " has condition 'cond', true value 'true' and false value 'false'";
}