Commit 2e0ccb2d authored by Luc Hermitte's avatar Luc Hermitte

ENH: OTB-134/OGR -> detailled assertions

parent 20a5cc18
......@@ -47,9 +47,9 @@ OGRDataSource & otb::ogr::DataSource::ogr()
inline
otb::ogr::Layer otb::ogr::DataSource::GetLayer(size_t i)
{
assert(int(i) < GetLayersCount());
assert(int(i) < GetLayersCount() && "Out-of-range index");
OGRLayer * layer_ptr = GetLayerUnchecked(i);
assert(layer_ptr);
assert(layer_ptr && "No layer returned by OGR");
return otb::ogr::Layer(layer_ptr);
}
......
......@@ -94,7 +94,7 @@ void otb::ogr::Feature::PrintSelf(std::ostream & os, itk::Indent indent) const
indent = indent.GetNextIndent();
for (size_t i=0; i!=nbFields; ++i)
{
assert(ogr().GetFieldDefnRef(i));
assert(ogr().GetFieldDefnRef(i) && "No definition associated to the i-th field");
Field const& field = (*this)[i];
field.PrintSelf(os, indent);
}
......@@ -205,9 +205,9 @@ void otb::ogr::Feature::SetGeometryDirectly(UniqueGeometryPtr geometry)
{
itkGenericExceptionMacro(<<"Cannot set (directly) the geometry: " << CPLGetLastErrorMsg());
}
assert(m_Feature->GetGeometryRef() == g);
assert(m_Feature->GetGeometryRef() == g && "The new geometry hasn't been set as expected");
geometry.release(); // success => commit the transaction (after any exception thrown)
assert(! geometry);
assert(! geometry && "UniqueGeometryPtr hasn't released its pointer");
}
otb::ogr::UniqueGeometryPtr otb::ogr::Feature::StealGeometry()
......@@ -215,7 +215,7 @@ otb::ogr::UniqueGeometryPtr otb::ogr::Feature::StealGeometry()
CheckInvariants();
OGRGeometry * g = m_Feature->StealGeometry();
UniqueGeometryPtr res(g);
assert(! m_Feature->GetGeometryRef());
assert(! m_Feature->GetGeometryRef() && "Geometry hasn't been properly stolen");
return UniqueGeometryPtr(g);
}
......
......@@ -277,9 +277,9 @@ typedef map
inline
void otb::ogr::Field::CheckInvariants() const
{
assert(m_Feature);
assert(int(m_index) < m_Feature->GetFieldCount());
assert(m_Feature->GetFieldDefnRef(m_index));
assert(m_Feature && "OGR Fields must be associated to a valid feature");
assert(int(m_index) < m_Feature->GetFieldCount() && "Out-of-range index for a OGR field");
assert(m_Feature->GetFieldDefnRef(m_index) && "No definition available for the OGR field");
}
template <typename T>
......@@ -290,7 +290,7 @@ void otb::ogr::Field::SetValue(T const& value)
const int VALUE = boost::mpl::at<internal::FieldType_Map, T>::type::value;
typedef typename boost::mpl::at<internal::FieldType_Map, T>::type Kind;
BOOST_STATIC_ASSERT(!(boost::is_same<Kind, boost::mpl::void_>::value));
assert(m_Definition.GetType() == Kind::value);
assert(m_Definition.GetType() == Kind::value && "OGR field type mismatches the type of new field value");
typedef typename boost::mpl::at<internal::FieldSetters_Map, Kind>::type SetterType;
BOOST_STATIC_ASSERT(!(boost::is_same<SetterType, boost::mpl::void_>::value));
SetterType::call(*m_Feature, m_index, value);
......@@ -305,7 +305,7 @@ T otb::ogr::Field::GetValue() const
const int VALUE = boost::mpl::at<internal::FieldType_Map, T>::type::value;
typedef typename boost::mpl::at<internal::FieldType_Map, T>::type Kind;
BOOST_STATIC_ASSERT(!(boost::is_same<Kind, boost::mpl::void_>::value));
assert(m_Definition.GetType() == Kind::value);
assert(m_Definition.GetType() == Kind::value && "OGR field type mismatches the type of requested field value");
typedef typename boost::mpl::at<internal::FieldGetters_Map, Kind>::type GetterType;
BOOST_STATIC_ASSERT(!(boost::is_same<GetterType, boost::mpl::void_>::value));
return GetterType::call(*m_Feature, m_index);
......
......@@ -59,7 +59,7 @@ otb::ogr::Layer::Layer(OGRLayer* layer, OGRDataSource& sourceInChargeOfLifeTime)
/*===========================================================================*/
int otb::ogr::Layer::GetFeatureCount(bool doForceComputation) const
{
assert(m_Layer);
assert(m_Layer && "Can't ask the features count on an invalid layer");
return m_Layer->GetFeatureCount(doForceComputation);
}
......
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