From 959cef51a9386bfbb710bf1299577c281a55b545 Mon Sep 17 00:00:00 2001
From: Walter Van Herck <w.van.herck@fz-juelich.de>
Date: Thu, 1 Feb 2018 15:55:51 +0100
Subject: [PATCH] Remove macro EXPECT

---
 GUI/ba3d/ba3d/def.cpp                          |  2 +-
 GUI/ba3d/ba3d/def.h                            |  2 --
 GUI/ba3d/ba3d/model/geometry.cpp               |  8 ++++----
 GUI/ba3d/ba3d/model/geometry/cuboctahedron.cpp |  4 ++--
 GUI/ba3d/ba3d/model/model.cpp                  |  8 +++++---
 GUI/ba3d/ba3d/view/canvas.cpp                  |  2 +-
 GUI/ba3d/demo/demo_model.cpp                   |  2 +-
 GUI/ba3d/demo/lattice.cpp                      | 10 +++++-----
 GUI/ba3d/demo/mainwin.cpp                      |  2 +-
 9 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/GUI/ba3d/ba3d/def.cpp b/GUI/ba3d/ba3d/def.cpp
index c3868c00083..2ed9f1eae20 100644
--- a/GUI/ba3d/ba3d/def.cpp
+++ b/GUI/ba3d/ba3d/def.cpp
@@ -23,7 +23,7 @@ namespace ba3d {
 #ifndef NDEBUG
 
 flp::flp(flt f_) : f(f_) {
-  EXPECT(0 <= f)
+  Q_ASSERT(0 <= f)
 }
 
 #endif
diff --git a/GUI/ba3d/ba3d/def.h b/GUI/ba3d/ba3d/def.h
index a0df73a850f..cbf527ac05b 100644
--- a/GUI/ba3d/ba3d/def.h
+++ b/GUI/ba3d/ba3d/def.h
@@ -37,8 +37,6 @@
 // trace print
 #define WT(what) TR(#what << what)
 
-// precondition
-#define EXPECT(cond) Q_ASSERT(cond);
 // invariant
 #define ENSURE(cond) Q_ASSERT(cond);
 
diff --git a/GUI/ba3d/ba3d/model/geometry.cpp b/GUI/ba3d/ba3d/model/geometry.cpp
index c1e184b0d66..2687f14165d 100644
--- a/GUI/ba3d/ba3d/model/geometry.cpp
+++ b/GUI/ba3d/ba3d/model/geometry.cpp
@@ -40,7 +40,7 @@ void Geometry::xyz_vec::addQuad(Geometry::xyz_vec::rc vs,
 }
 
 void Geometry::xyz_vec::addStrip(xyz_vec::rc vs, idx_vec::rc is) {
-  EXPECT(is.count() >= 3) // at least one triangle
+  Q_ASSERT(is.count() >= 3); // at least one triangle
   for_i (is.count() - 2)
     if (i%2)
       addTrig(vs.at(is.at(i)), vs.at(is.at(1+i)), vs.at(is.at(2+i)));
@@ -49,7 +49,7 @@ void Geometry::xyz_vec::addStrip(xyz_vec::rc vs, idx_vec::rc is) {
 }
 
 void Geometry::xyz_vec::addFan(xyz_vec::rc vs, idx_vec::rc is) {
-  EXPECT(is.count() >= 3) // at least one triangle
+  Q_ASSERT(is.count() >= 3); // at least one triangle
   auto &ctr = vs.at(is.at(0));
   for_i (is.count() - 2)
     addTrig(ctr, vs.at(is.at(1+i)),
@@ -96,8 +96,8 @@ Geometry::~Geometry() {
 
 Geometry::mesh_t Geometry::makeMesh(xyz_vec::rc vs, xyz_vec const* ns) {
   int nv = vs.count();
-  EXPECT(0 == nv%3)
-  EXPECT(!ns || nv == ns->count()) // if normals not given, will be computed
+  Q_ASSERT(0 == nv%3);
+  Q_ASSERT(!ns || nv == ns->count()); // if normals not given, will be computed
 
   mesh_t mesh(nv);
 
diff --git a/GUI/ba3d/ba3d/model/geometry/cuboctahedron.cpp b/GUI/ba3d/ba3d/model/geometry/cuboctahedron.cpp
index 4c9d0ecdc94..974a8312b63 100644
--- a/GUI/ba3d/ba3d/model/geometry/cuboctahedron.cpp
+++ b/GUI/ba3d/ba3d/model/geometry/cuboctahedron.cpp
@@ -19,8 +19,8 @@ namespace ba3d {
 //------------------------------------------------------------------------------
 
 Geometry::mesh_t Geometry::meshCuboctahedron(flt rH, flt alpha) { // t/D
-  EXPECT(alpha >= flt(M_PI_2))
-  EXPECT(rH >= 0)
+  Q_ASSERT(alpha >= flt(M_PI_2));
+  Q_ASSERT(rH >= 0);
 
   flt const D = .5f, H = 2*D / (rH + 1), t = tanf(alpha - flt(M_PI_2));
   flt const Db = D - t*H, Dt = D - t*(2*D - H);
diff --git a/GUI/ba3d/ba3d/model/model.cpp b/GUI/ba3d/ba3d/model/model.cpp
index 1003066529a..541e123989d 100644
--- a/GUI/ba3d/ba3d/model/model.cpp
+++ b/GUI/ba3d/ba3d/model/model.cpp
@@ -96,13 +96,15 @@ particle::Particle* Model::newParticle(particle::kind k, flp R) {
 }
 
 void Model::add(Object* o) {
-  EXPECT(o) EXPECT(!o->model)
+  Q_ASSERT(o);
+  Q_ASSERT(!o->model);
   o->model = this;
   objects.append(o);
 }
 
 void Model::addBlend(Object* o) {
-  EXPECT(o) EXPECT(!o->model)
+  Q_ASSERT(o);
+  Q_ASSERT(!o->model);
   o->model = this;
   objectsBlend.append(o);
 }
@@ -114,7 +116,7 @@ void Model::rem(Object* o) {
   else if ((i = objectsBlend.indexOf(o)) >= 0)
     objectsBlend.remove(i);
   else
-    EXPECT(false); // object not found, should not happen, bad caller!
+    Q_ASSERT(false); // object not found, should not happen, bad caller!
 
   o->releaseGeometry();
   o->model = nullptr;
diff --git a/GUI/ba3d/ba3d/view/canvas.cpp b/GUI/ba3d/ba3d/view/canvas.cpp
index 1d27d562dea..f94466d1361 100644
--- a/GUI/ba3d/ba3d/view/canvas.cpp
+++ b/GUI/ba3d/ba3d/view/canvas.cpp
@@ -190,7 +190,7 @@ void Canvas::draw(QColor const& color, QMatrix4x4 const& mat, Geometry const& ge
   else
     buf = *it;
 
-  EXPECT(program)
+  Q_ASSERT(program);
   program->set(color);
   program->set(mat);
   buf->draw();
diff --git a/GUI/ba3d/demo/demo_model.cpp b/GUI/ba3d/demo/demo_model.cpp
index dac5452301e..a8f48e9c847 100644
--- a/GUI/ba3d/demo/demo_model.cpp
+++ b/GUI/ba3d/demo/demo_model.cpp
@@ -93,7 +93,7 @@ void DemoModel::square(float sigma) {
     activeMesh.clear();
   }
 
-  EXPECT (ps.count() == mesh.count())
+  Q_ASSERT(ps.count() == mesh.count());
 
   if (activeMesh.empty()) {
     activeMesh = mesh;
diff --git a/GUI/ba3d/demo/lattice.cpp b/GUI/ba3d/demo/lattice.cpp
index 2cbb4377a53..c44d3d174c1 100644
--- a/GUI/ba3d/demo/lattice.cpp
+++ b/GUI/ba3d/demo/lattice.cpp
@@ -25,8 +25,8 @@ Lattice::Lattice(uint n_, uint nn) : super (nn), n(n_) {}
 
 uint Lattice::index(int ix, int iy) {
   int nx = n, ny = n;
-  EXPECT (-nx <= ix && ix <= +nx)
-  EXPECT (-ny <= iy && iy <= +ny)
+  Q_ASSERT(-nx <= ix && ix <= +nx);
+  Q_ASSERT(-ny <= iy && iy <= +ny);
   uint i = (2*nx + 1) * (iy + ny) + (ix + nx);
   ENSURE (static_cast<int>(i) < count())
   return i;
@@ -96,8 +96,8 @@ Lattice squareLattice(uint n, float sigma) {
   };
 
   auto growBy1Quadrant = [&](uint n, int mx, int my) {
-    EXPECT (n > 0)
-    EXPECT (1 == qAbs(mx) && 1 == qAbs(my))
+    Q_ASSERT(n > 0);
+    Q_ASSERT(1 == qAbs(mx) && 1 == qAbs(my));
 
     put(0*mx, n*my); put(n*mx, 0*my);
 
@@ -109,7 +109,7 @@ Lattice squareLattice(uint n, float sigma) {
   };
 
   auto growBy1 = [&](uint n) {
-    EXPECT (n > 0)
+    Q_ASSERT(n > 0);
     growBy1Quadrant(n, +1, +1);
     growBy1Quadrant(n, +1, -1);
     growBy1Quadrant(n, -1, +1);
diff --git a/GUI/ba3d/demo/mainwin.cpp b/GUI/ba3d/demo/mainwin.cpp
index 2408e014f28..7658749527f 100644
--- a/GUI/ba3d/demo/mainwin.cpp
+++ b/GUI/ba3d/demo/mainwin.cpp
@@ -117,7 +117,7 @@ void MainWin::createLayout() {
 
 DemoModel* MainWin::model() {
   auto model = dynamic_cast<DemoModel*>(w3d->getModel());
-  EXPECT(model)
+  Q_ASSERT(model);
   return model;
 }
 
-- 
GitLab