1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

Merge pull request #21107 from take1014:remove_assert_21038

resolves #21038

* remove C assert

* revert C header

* fix several points in review

* fix test_ds.cpp
This commit is contained in:
yuki takehara
2021-11-28 03:34:52 +09:00
committed by GitHub
parent b55d8f46f4
commit a6277370ca
81 changed files with 277 additions and 286 deletions
+25 -21
View File
@@ -33,7 +33,7 @@ static void cvTsReleaseSimpleSeq( CvTsSimpleSeq** seq )
static schar* cvTsSimpleSeqElem( CvTsSimpleSeq* seq, int index )
{
assert( 0 <= index && index < seq->count );
CV_Assert( 0 <= index && index < seq->count );
return seq->array + index * seq->elem_size;
}
@@ -50,7 +50,11 @@ static void cvTsSimpleSeqShiftAndCopy( CvTsSimpleSeq* seq, int from_idx, int to_
if( from_idx == to_idx )
return;
assert( (from_idx > to_idx && !elem) || (from_idx < to_idx && elem) );
if (elem)
CV_Assert(from_idx < to_idx);
else
CV_Assert(from_idx > to_idx);
if( from_idx < seq->count )
{
@@ -128,7 +132,7 @@ static void cvTsReleaseSimpleSet( CvTsSimpleSet** set_header )
static schar* cvTsSimpleSetFind( CvTsSimpleSet* set_header, int index )
{
int idx = index * set_header->elem_size;
assert( 0 <= index && index < set_header->max_count );
CV_Assert( 0 <= index && index < set_header->max_count );
return set_header->array[idx] ? set_header->array + idx + 1 : 0;
}
@@ -136,11 +140,11 @@ static schar* cvTsSimpleSetFind( CvTsSimpleSet* set_header, int index )
static int cvTsSimpleSetAdd( CvTsSimpleSet* set_header, void* elem )
{
int idx, idx2;
assert( set_header->free_count > 0 );
CV_Assert( set_header->free_count > 0 );
idx = set_header->free_stack[--set_header->free_count];
idx2 = idx * set_header->elem_size;
assert( set_header->array[idx2] == 0 );
CV_Assert( set_header->array[idx2] == 0 );
set_header->array[idx2] = 1;
if( set_header->elem_size > 1 )
memcpy( set_header->array + idx2 + 1, elem, set_header->elem_size - 1 );
@@ -152,9 +156,9 @@ static int cvTsSimpleSetAdd( CvTsSimpleSet* set_header, void* elem )
static void cvTsSimpleSetRemove( CvTsSimpleSet* set_header, int index )
{
assert( set_header->free_count < set_header->max_count &&
0 <= index && index < set_header->max_count );
assert( set_header->array[index * set_header->elem_size] == 1 );
CV_Assert( set_header->free_count < set_header->max_count &&
0 <= index && index < set_header->max_count );
CV_Assert( set_header->array[index * set_header->elem_size] == 1 );
set_header->free_stack[set_header->free_count++] = index;
set_header->array[index * set_header->elem_size] = 0;
@@ -187,7 +191,7 @@ static CvTsSimpleGraph* cvTsCreateSimpleGraph( int max_vtx_count, int vtx_size,
{
CvTsSimpleGraph* graph;
assert( max_vtx_count > 1 && vtx_size >= 0 && edge_size >= 0 );
CV_Assert( max_vtx_count > 1 && vtx_size >= 0 && edge_size >= 0 );
graph = (CvTsSimpleGraph*)cvAlloc( sizeof(*graph) +
max_vtx_count * max_vtx_count * (edge_size + 1));
graph->vtx = cvTsCreateSimpleSet( max_vtx_count, vtx_size );
@@ -235,13 +239,13 @@ static void cvTsSimpleGraphAddEdge( CvTsSimpleGraph* graph, int idx1, int idx2,
{
int i, t, n = graph->oriented ? 1 : 2;
assert( cvTsSimpleSetFind( graph->vtx, idx1 ) &&
cvTsSimpleSetFind( graph->vtx, idx2 ));
CV_Assert( cvTsSimpleSetFind( graph->vtx, idx1 ) &&
cvTsSimpleSetFind( graph->vtx, idx2 ));
for( i = 0; i < n; i++ )
{
int ofs = (idx1*graph->vtx->max_count + idx2)*graph->edge_size;
assert( graph->matrix[ofs] == 0 );
CV_Assert( graph->matrix[ofs] == 0 );
graph->matrix[ofs] = 1;
if( graph->edge_size > 1 )
memcpy( graph->matrix + ofs + 1, edge, graph->edge_size - 1 );
@@ -255,13 +259,13 @@ static void cvTsSimpleGraphRemoveEdge( CvTsSimpleGraph* graph, int idx1, int id
{
int i, t, n = graph->oriented ? 1 : 2;
assert( cvTsSimpleSetFind( graph->vtx, idx1 ) &&
CV_Assert( cvTsSimpleSetFind( graph->vtx, idx1 ) &&
cvTsSimpleSetFind( graph->vtx, idx2 ));
for( i = 0; i < n; i++ )
{
int ofs = (idx1*graph->vtx->max_count + idx2)*graph->edge_size;
assert( graph->matrix[ofs] == 1 );
CV_Assert( graph->matrix[ofs] == 1 );
graph->matrix[ofs] = 0;
CV_SWAP( idx1, idx2, t );
}
@@ -291,7 +295,7 @@ static int cvTsSimpleGraphVertexDegree( CvTsSimpleGraph* graph, int index )
int i, count = 0;
int edge_size = graph->edge_size;
int max_vtx_count = graph->vtx->max_count;
assert( cvTsSimpleGraphFindVertex( graph, index ) != 0 );
CV_Assert( cvTsSimpleGraphFindVertex( graph, index ) != 0 );
for( i = 0; i < max_vtx_count; i++ )
{
@@ -301,7 +305,7 @@ static int cvTsSimpleGraphVertexDegree( CvTsSimpleGraph* graph, int index )
if( !graph->oriented )
{
assert( count % 2 == 0 );
CV_Assert( count % 2 == 0 );
count /= 2;
}
return count;
@@ -609,7 +613,7 @@ int Core_SeqBaseTest::test_get_seq_elem( int _struct_idx, int iters )
CvTsSimpleSeq* sseq = (CvTsSimpleSeq*)simple_struct[_struct_idx];
struct_idx = _struct_idx;
assert( seq->total == sseq->count );
CV_Assert( seq->total == sseq->count );
if( sseq->count == 0 )
return 0;
@@ -656,7 +660,7 @@ int Core_SeqBaseTest::test_get_seq_reading( int _struct_idx, int iters )
vector<schar> _elem(sseq->elem_size);
schar* elem = &_elem[0];
assert( total == sseq->count );
CV_Assert( total == sseq->count );
this->struct_idx = _struct_idx;
int pos = cvtest::randInt(rng) % 2;
@@ -964,7 +968,7 @@ int Core_SeqBaseTest::test_seq_ops( int iters )
"The sequence doesn't become empty after clear" );
break;
default:
assert(0);
CV_Assert(0);
return -1;
}
@@ -1903,7 +1907,7 @@ int Core_GraphScanTest::create_random_graph( int _struct_idx )
for( i = 0; i < vtx_count; i++ )
cvGraphAddVtx( graph );
assert( graph->active_count == vtx_count );
CV_Assert( graph->active_count == vtx_count );
for( i = 0; i < edge_count; i++ )
{
@@ -1914,7 +1918,7 @@ int Core_GraphScanTest::create_random_graph( int _struct_idx )
cvGraphAddEdge( graph, j, k );
}
assert( graph->active_count == vtx_count && graph->edges->active_count <= edge_count );
CV_Assert( graph->active_count == vtx_count && graph->edges->active_count <= edge_count );
return 0;
}