Commit c3fc7426 authored by Damien L-G's avatar Damien L-G

Define ASSERT macro to use in the tests instead of the C macro assert

parent ef9f60f7
#ifndef NONAME_ASSERTION_MACROS
#define NONAME_ASSERTION_MACROS
#include <cassert>
#include <cstdlib>
#include <iostream>
......@@ -31,5 +30,13 @@
std::abort(); \
} \
}
#define ASSERT(condition) \
{ \
if (!bool(condition)) { \
std::cerr << __FILE__ << ":" << __LINE__ << " assertion `" << #condition \
<< "' failed\n"; \
std::abort(); \
} \
}
#endif
......@@ -2,7 +2,6 @@
#include <Spline2D.hpp>
#include <TestAssertionMacros.hpp>
#include <cassert>
#include <stdexcept>
#include <string>
......@@ -45,16 +44,16 @@ template <typename Spline> void invalid_number_of_options() {
template <typename Spline> void control_map_growth() {
Map<Spline>::clear();
assert(Map<Spline>::size() == 0);
ASSERT(Map<Spline>::size() == 0);
Map<Spline>::get_spline(":dummy.csv: :dummy.csv: :dummy.csv:");
Map<Spline>::get_spline(":dummy.csv: :dummy.csv: :dummy.csv:");
assert(Map<Spline>::size() == 1);
ASSERT(Map<Spline>::size() == 1);
Map<Spline>::get_spline("|dummy.csv |dummy.csv |dummy.csv");
Map<Spline>::get_spline("? dummy.csv? ? ? ?dummy.csv???dummy.csv");
assert(Map<Spline>::size() == 3);
ASSERT(Map<Spline>::size() == 3);
Map<Spline>::get_spline(":dummy.csv: :dummy.csv: :dummy.csv:");
assert(Map<Spline>::size() == 3);
ASSERT(Map<Spline>::size() == 3);
}
int main() {
......
......@@ -3,7 +3,6 @@
#include <gsl/gsl_interp2d.h>
#include <cassert>
#include <cstddef>
#include <cstdlib>
#include <iostream>
......@@ -143,7 +142,7 @@ template <typename T> void eval_at_grid_points() {
double const tolerance = 1e-12;
for (auto xi : x) {
for (auto yj : y) {
assert(fp_close(spline.eval(xi, yj), func(xi, yj), tolerance));
ASSERT(fp_close(spline.eval(xi, yj), func(xi, yj), tolerance));
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment