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