template<typename T> inline
 AssertionError assertEQ_(T const & a
                         ,T const & b
                         ,std::string const & sa
                         ,std::string const & sb
                         ,std::string const & file
                         ,unsigned int const line
                         ,std::string const & function
                         ,std::string const & msg
                         )
 {
     return AssertionError(msg + "; "  + sa + " == " + xtos(a) + " !== " + xtos(b) + " == " + sb,file,line,function);
 }
Beispiel #2
0
// Check for identically zero polynomials using randomized polynomial identity testing
template<class R,class PerturbedT> static void
assert_last_nonzero(void(*const polynomial)(R,RawArray<const Vector<Exact<1>,PerturbedT::m>>),
                    R result, RawArray<const PerturbedT> X, const char* message) {

  typedef Vector<Exact<1>,PerturbedT::m> EV;
  const int n = X.size();
  const auto Z = GEODE_RAW_ALLOCA(n,EV);
  for (const int k : range(20)) {
    for (int i=0;i<n;i++)
      Z[i] = EV(perturbation<PerturbedT::m>(k<<10,X[i].seed()));
    polynomial(result,Z);
    if (last_nonzero(result)) // Even a single nonzero means we're all good
      return;
  }
  // If we reach this point, the chance of a nonzero nonmalicious polynomial is something like (1e-5)^20 = 1e-100.  Thus, we can safely assume that for the lifetime
  // of this code, we will never treat a nonzero polynomial as zero.  If this comes up, we can easily bump the threshold a bit further.
  throw AssertionError(format("%s (there is likely a bug in the calling code), X = %s",message,str(X)));
}
Beispiel #3
0
//--------------------------------------------------------------------------------
//
// __assert__
//
// 이 함수에서는 __BEGIN_TRY , __END_CATCH로 wrapping할 필요가 없다.
//
//--------------------------------------------------------------------------------
void __assert__ (const char * file , uint line , const char * func , const char * expr )
	throw(AssertionError )
{
	StringStream msg;
	
	msg << "\nAssertion Failed : " << file << " : " << line;

	if (func )
		msg << " : " << func;

	time_t currentTime = time(0);
	
	msg << expr << " at " << ctime(&currentTime);
	
	ofstream ofile("assertion_failed.log",ios::app);
	ofile << msg.toString() << endl;
	ofile.close();

	throw AssertionError(msg.toString());
}