12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- #ifdef RA_DO_CHECK
- #undef RA_DO_CHECK
- #define RA_DO_CHECK 1
- #endif
- #include <exception>
- #include <string>
- #include "ra/bootstrap.hh"
- struct ra_error: public std::exception
- {
- std::string s;
- template <class ... A> ra_error(A && ... a): s(ra::format(std::forward<A>(a) ...)) {}
- virtual char const * what() const throw ()
- {
- return s.c_str();
- }
- };
- #define RA_ASSERT( cond, ... ) \
- { if (!( cond )) throw ra_error("ra:: assert [" STRINGIZE(cond) "] " __VA_OPT__(,) __VA_ARGS__); }
- #include "ra/ra.hh"
- #include "ra/test.hh"
- #include <iostream>
- using std::cout, std::endl, ra::TestRecorder;
- int main()
- {
- TestRecorder tr(cout);
- bool yes = false;
- ra::Big<int> a({2, 3}, 9);
- std::string msg;
- try {
- cout << a(2, 3) << endl;
- } catch (ra_error & e) {
- msg = e.what();
- yes = true;
- }
- tr.info(msg).test(yes);
- return tr.summary();
- }
|