replace all casserts with Boost.Assert
This commit is contained in:
parent
5f80c33b24
commit
6453cdf0d6
@ -32,7 +32,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <boost/unordered_map.hpp>
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
@ -159,7 +159,7 @@ public:
|
||||
}
|
||||
|
||||
bool WasRemoved( const NodeID node ) {
|
||||
assert( WasInserted( node ) );
|
||||
BOOST_ASSERT( WasInserted( node ) );
|
||||
const Key index = nodeIndex[node];
|
||||
return insertedNodes[index].key == 0;
|
||||
}
|
||||
@ -172,12 +172,12 @@ public:
|
||||
}
|
||||
|
||||
NodeID Min() const {
|
||||
assert( heap.size() > 1 );
|
||||
BOOST_ASSERT( heap.size() > 1 );
|
||||
return insertedNodes[heap[1].index].node;
|
||||
}
|
||||
|
||||
NodeID DeleteMin() {
|
||||
assert( heap.size() > 1 );
|
||||
BOOST_ASSERT( heap.size() > 1 );
|
||||
const Key removedIndex = heap[1].index;
|
||||
heap[1] = heap[heap.size()-1];
|
||||
heap.pop_back();
|
||||
@ -196,10 +196,10 @@ public:
|
||||
}
|
||||
|
||||
void DecreaseKey( NodeID node, Weight weight ) {
|
||||
assert( UINT_MAX != node );
|
||||
BOOST_ASSERT( UINT_MAX != node );
|
||||
const Key & index = nodeIndex[node];
|
||||
Key & key = insertedNodes[index].key;
|
||||
assert ( key >= 0 );
|
||||
BOOST_ASSERT ( key >= 0 );
|
||||
|
||||
insertedNodes[index].weight = weight;
|
||||
heap[key].weight = weight;
|
||||
@ -257,7 +257,7 @@ private:
|
||||
const Weight weight = heap[key].weight;
|
||||
Key nextKey = key >> 1;
|
||||
while ( heap[nextKey].weight > weight ) {
|
||||
assert( nextKey != 0 );
|
||||
BOOST_ASSERT( nextKey != 0 );
|
||||
heap[key] = heap[nextKey];
|
||||
insertedNodes[heap[key].index].key = key;
|
||||
key = nextKey;
|
||||
@ -271,7 +271,7 @@ private:
|
||||
void CheckHeap() {
|
||||
#ifndef NDEBUG
|
||||
for ( Key i = 2; i < (Key) heap.size(); ++i ) {
|
||||
assert( heap[i].weight >= heap[i >> 1].weight );
|
||||
BOOST_ASSERT( heap[i].weight >= heap[i >> 1].weight );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "../DataStructures/MercatorUtil.h"
|
||||
#include "../Util/StringUtil.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
#include <cmath>
|
||||
#include <climits>
|
||||
|
||||
@ -74,10 +74,10 @@ inline std::ostream & operator<<(std::ostream & out, const FixedPointCoordinate
|
||||
}
|
||||
|
||||
inline double ApproximateDistance( const int lat1, const int lon1, const int lat2, const int lon2 ) {
|
||||
assert(lat1 != INT_MIN);
|
||||
assert(lon1 != INT_MIN);
|
||||
assert(lat2 != INT_MIN);
|
||||
assert(lon2 != INT_MIN);
|
||||
BOOST_ASSERT(lat1 != INT_MIN);
|
||||
BOOST_ASSERT(lon1 != INT_MIN);
|
||||
BOOST_ASSERT(lat2 != INT_MIN);
|
||||
BOOST_ASSERT(lon2 != INT_MIN);
|
||||
double RAD = 0.017453292519943295769236907684886;
|
||||
double lt1 = lat1/COORDINATE_PRECISION;
|
||||
double ln1 = lon1/COORDINATE_PRECISION;
|
||||
@ -106,10 +106,10 @@ inline double ApproximateDistance(const FixedPointCoordinate &c1, const FixedPoi
|
||||
}
|
||||
|
||||
inline double ApproximateEuclideanDistance(const FixedPointCoordinate &c1, const FixedPointCoordinate &c2) {
|
||||
assert(c1.lat != INT_MIN);
|
||||
assert(c1.lon != INT_MIN);
|
||||
assert(c2.lat != INT_MIN);
|
||||
assert(c2.lon != INT_MIN);
|
||||
BOOST_ASSERT(c1.lat != INT_MIN);
|
||||
BOOST_ASSERT(c1.lon != INT_MIN);
|
||||
BOOST_ASSERT(c2.lat != INT_MIN);
|
||||
BOOST_ASSERT(c2.lon != INT_MIN);
|
||||
const double RAD = 0.017453292519943295769236907684886;
|
||||
const double lat1 = (c1.lat/COORDINATE_PRECISION)*RAD;
|
||||
const double lon1 = (c1.lon/COORDINATE_PRECISION)*RAD;
|
||||
|
@ -28,7 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#ifndef DEALLOCATINGVECTOR_H_
|
||||
#define DEALLOCATINGVECTOR_H_
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
@ -103,7 +103,7 @@ public:
|
||||
|
||||
template<typename T2>
|
||||
DeallocatingVectorIterator& operator=(const DeallocatingVectorIterator<T2> &r) {
|
||||
if(DeallocateC) assert(false);
|
||||
if(DeallocateC) BOOST_ASSERT(false);
|
||||
mState = r.mState; return *this;
|
||||
}
|
||||
|
||||
@ -113,7 +113,7 @@ public:
|
||||
}
|
||||
|
||||
inline DeallocatingVectorIterator& operator--() { //prefix
|
||||
if(DeallocateC) assert(false);
|
||||
if(DeallocateC) BOOST_ASSERT(false);
|
||||
--mState.mIndex;
|
||||
return *this;
|
||||
}
|
||||
@ -124,7 +124,7 @@ public:
|
||||
return DeallocatingVectorIterator(_myState);
|
||||
}
|
||||
inline DeallocatingVectorIterator operator--(int) { //postfix
|
||||
if(DeallocateC) assert(false);
|
||||
if(DeallocateC) BOOST_ASSERT(false);
|
||||
DeallocatingVectorIteratorState _myState(mState);
|
||||
mState.mIndex--;
|
||||
return DeallocatingVectorIterator(_myState);
|
||||
@ -141,14 +141,14 @@ public:
|
||||
}
|
||||
|
||||
inline DeallocatingVectorIterator operator-(const difference_type& n) const {
|
||||
if(DeallocateC) assert(false);
|
||||
if(DeallocateC) BOOST_ASSERT(false);
|
||||
DeallocatingVectorIteratorState _myState(mState);
|
||||
_myState.mIndex-=n;
|
||||
return DeallocatingVectorIterator(_myState);
|
||||
}
|
||||
|
||||
inline DeallocatingVectorIterator& operator-=(const difference_type &n) const {
|
||||
if(DeallocateC) assert(false);
|
||||
if(DeallocateC) BOOST_ASSERT(false);
|
||||
mState.mIndex-=n; return *this;
|
||||
}
|
||||
|
||||
@ -185,7 +185,7 @@ public:
|
||||
}
|
||||
|
||||
difference_type operator-(const DeallocatingVectorIterator & other) {
|
||||
if(DeallocateC) assert(false);
|
||||
if(DeallocateC) BOOST_ASSERT(false);
|
||||
return mState.mIndex-other.mState.mIndex;
|
||||
}
|
||||
};
|
||||
|
@ -28,7 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#ifndef SIMPLESTACK_H_
|
||||
#define SIMPLESTACK_H_
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
#include <vector>
|
||||
|
||||
template<typename StackItemT, class ContainerT = std::vector<StackItemT> >
|
||||
@ -61,7 +61,7 @@ public:
|
||||
}
|
||||
|
||||
inline StackItemT top() {
|
||||
assert (last >= 0);
|
||||
BOOST_ASSERT (last >= 0);
|
||||
return arr[last];
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#ifndef STATICKDTREE_H_INCLUDED
|
||||
#define STATICKDTREE_H_INCLUDED
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <stack>
|
||||
@ -100,8 +100,8 @@ public:
|
||||
};
|
||||
|
||||
StaticKDTree( std::vector< InputPoint > * points ){
|
||||
assert( k > 0 );
|
||||
assert ( points->size() > 0 );
|
||||
BOOST_ASSERT( k > 0 );
|
||||
BOOST_ASSERT ( points->size() > 0 );
|
||||
size = points->size();
|
||||
kdtree = new InputPoint[size];
|
||||
for ( Iterator i = 0; i != size; ++i ) {
|
||||
@ -209,11 +209,11 @@ private:
|
||||
public:
|
||||
Less( unsigned d ) {
|
||||
dimension = d;
|
||||
assert( dimension < k );
|
||||
BOOST_ASSERT( dimension < k );
|
||||
}
|
||||
|
||||
bool operator() ( const InputPoint& left, const InputPoint& right ) {
|
||||
assert( dimension < k );
|
||||
BOOST_ASSERT( dimension < k );
|
||||
return left.coordinates[dimension] < right.coordinates[dimension];
|
||||
}
|
||||
private:
|
||||
|
@ -35,7 +35,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "../Util/StringUtil.h"
|
||||
#include "../typedefs.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
|
||||
|
@ -42,7 +42,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <boost/unordered_map.hpp>
|
||||
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
|
||||
#include <algorithm>
|
||||
@ -158,7 +157,7 @@ NodeID readBinaryOSRMGraphFromStream(
|
||||
if (1 == dir) { backward = false; }
|
||||
if (2 == dir) { forward = false; }
|
||||
|
||||
assert(type >= 0);
|
||||
BOOST_ASSERT(type >= 0);
|
||||
|
||||
// translate the external NodeIDs to internal IDs
|
||||
ExternalNodeMap::iterator intNodeID = ext_to_int_id_map.find(source);
|
||||
@ -308,12 +307,12 @@ NodeID readDTMPGraphFromStream(std::istream &in, std::vector<EdgeT>& edgeList, s
|
||||
if(speedType == 13) {
|
||||
weight = length;
|
||||
}
|
||||
assert(length > 0);
|
||||
assert(weight > 0);
|
||||
BOOST_ASSERT(length > 0);
|
||||
BOOST_ASSERT(weight > 0);
|
||||
if(dir <0 || dir > 2) {
|
||||
SimpleLogger().Write(logWARNING) << "direction bogus: " << dir;
|
||||
}
|
||||
assert(0<=dir && dir<=2);
|
||||
BOOST_ASSERT(0<=dir && dir<=2);
|
||||
|
||||
bool forward = true;
|
||||
bool backward = true;
|
||||
@ -373,11 +372,11 @@ NodeID readDDSGGraphFromStream(std::istream &in, std::vector<EdgeT>& edgeList, s
|
||||
EdgeWeight weight;
|
||||
in >> source >> target >> weight >> dir;
|
||||
|
||||
assert(weight > 0);
|
||||
BOOST_ASSERT(weight > 0);
|
||||
if(dir <0 || dir > 3) {
|
||||
throw OSRMException( "[error] direction bogus");
|
||||
}
|
||||
assert(0<=dir && dir<=3);
|
||||
BOOST_ASSERT(0<=dir && dir<=3);
|
||||
|
||||
bool forward = true;
|
||||
bool backward = true;
|
||||
|
Loading…
Reference in New Issue
Block a user