mirror of https://github.com/CGAL/cgal
Merge pull request #302 from gdamiand/STL_extension-isused_test-gdamiand
STL Extensions: add test for is_used
This commit is contained in:
commit
35d63a2fb4
|
|
@ -55,14 +55,10 @@ bool test2D()
|
|||
dh = map.create_dart ();
|
||||
dh2 = map.create_dart();
|
||||
|
||||
if (!map.is_dart_used(dh) ) return false;
|
||||
|
||||
if ( map.is_valid() ) cout << "Map valid." << endl;
|
||||
cout << "Nombre de brins : " << map.number_of_darts() << endl;
|
||||
map.clear();
|
||||
|
||||
if ( map.is_dart_used(dh) ) return false;
|
||||
|
||||
cout << "***************************** TEST BASIC CREATION 2D DONE."
|
||||
<< endl;
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ if ( CGAL_FOUND )
|
|||
create_single_source_cgal_program( "test_Boolean_tag.cpp" )
|
||||
create_single_source_cgal_program( "test_Cache.cpp" )
|
||||
create_single_source_cgal_program( "test_Compact_container.cpp" )
|
||||
create_single_source_cgal_program( "test_Compact_container_is_used.cpp" )
|
||||
create_single_source_cgal_program( "test_complexity_tags.cpp" )
|
||||
create_single_source_cgal_program( "test_composition.cpp" )
|
||||
create_single_source_cgal_program( "test_Concatenate_iterator.cpp" )
|
||||
|
|
|
|||
|
|
@ -0,0 +1,71 @@
|
|||
// test program for Compact_container.
|
||||
|
||||
#include <CGAL/Compact_container.h>
|
||||
|
||||
class Node_1
|
||||
{
|
||||
union {
|
||||
Node_1 * p;
|
||||
void * p_cc;
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
Node_1() : p(NULL)
|
||||
{}
|
||||
|
||||
void * for_compact_container() const { return p_cc; }
|
||||
void * & for_compact_container() { return p_cc; }
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef CGAL::Compact_container<Node_1> C1;
|
||||
|
||||
C1 c1;
|
||||
if (!c1.empty())
|
||||
{
|
||||
std::cout<<"PB new container is not empty."<<std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
std::size_t nb=0;
|
||||
for (nb = 0 ; nb < 10000 ; ++nb)
|
||||
{
|
||||
C1::iterator it=c1.emplace();
|
||||
if ( !c1.is_used(it) )
|
||||
{
|
||||
std::cout<<"PB new emplace element is not used."<<std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if ( !c1.is_used(nb) )
|
||||
{
|
||||
std::cout<<"PB new emplace element is not used (2)."<<std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
nb=0;
|
||||
for (C1::iterator it = c1.begin(), itend=c1.end(); it!=itend; ++it, ++nb)
|
||||
{
|
||||
c1.erase(it);
|
||||
if ( c1.is_used(it) )
|
||||
{
|
||||
std::cout<<"PB erase element is used."<<std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if ( c1.is_used(nb) )
|
||||
{
|
||||
std::cout<<"PB erase element is used (2)."<<std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!c1.empty())
|
||||
{
|
||||
std::cout<<"PB container at the end is not empty."<<std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Loading…
Reference in New Issue