mirror of https://github.com/CGAL/cgal
Switch to std::string in order to avoid a new/delete mismatch error in test code
This commit is contained in:
parent
c7d4d3a99c
commit
8189bf8d97
24
Segment_Delaunay_graph_2/test/Segment_Delaunay_graph_2/include/test_types.h
Normal file → Executable file
24
Segment_Delaunay_graph_2/test/Segment_Delaunay_graph_2/include/test_types.h
Normal file → Executable file
|
|
@ -8,6 +8,7 @@
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "IO/Null_output_stream.h"
|
#include "IO/Null_output_stream.h"
|
||||||
#include "IO/io_aux.h"
|
#include "IO/io_aux.h"
|
||||||
|
|
@ -17,24 +18,18 @@
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
template<class NT>
|
template<class NT>
|
||||||
char* get_fname(const NT&, const char* ifname) {
|
std::string get_fname(const NT&, std::string ifname)
|
||||||
char* fname = new char[50];
|
{
|
||||||
std::strcpy(fname, "data/");
|
return std::string("data/") + ifname + ".cin";
|
||||||
std::strcat(fname, ifname);
|
|
||||||
std::strcat(fname, ".cin");
|
|
||||||
return fname;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CGAL_USE_GMP
|
#ifdef CGAL_USE_GMP
|
||||||
#include <CGAL/Gmpq.h>
|
#include <CGAL/Gmpq.h>
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
char* get_fname(const CGAL::Gmpq&, const char* ifname) {
|
std::string get_fname(const CGAL::Gmpq&, std::string ifname)
|
||||||
char* fname = new char[50];
|
{
|
||||||
std::strcpy(fname, "data/");
|
return std::string("data/") + ifname + ".Gmpq.cin";
|
||||||
std::strcat(fname, ifname);
|
|
||||||
std::strcat(fname, ".Gmpq.cin");
|
|
||||||
return fname;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -79,7 +74,7 @@ template<class SDG, class InputStream>
|
||||||
bool test_sdg(InputStream&, const SDG&, const char* ifname, const char* ofname,
|
bool test_sdg(InputStream&, const SDG&, const char* ifname, const char* ofname,
|
||||||
bool test_remove)
|
bool test_remove)
|
||||||
{
|
{
|
||||||
char* ifname_full = get_fname(typename SDG2::Geom_traits::FT(), ifname);
|
std::string ifname_full = get_fname(typename SDG2::Geom_traits::FT(), ifname);
|
||||||
|
|
||||||
typedef SDG SDG2;
|
typedef SDG SDG2;
|
||||||
|
|
||||||
|
|
@ -366,7 +361,7 @@ bool test_sdg(InputStream&, const SDG&, const char* ifname, const char* ofname,
|
||||||
{
|
{
|
||||||
sdg.clear();
|
sdg.clear();
|
||||||
|
|
||||||
std::ifstream ifs( ifname_full );
|
std::ifstream ifs( ifname_full.c_str() );
|
||||||
assert( ifs );
|
assert( ifs );
|
||||||
Site_2 t;
|
Site_2 t;
|
||||||
while ( ifs >> t ) {
|
while ( ifs >> t ) {
|
||||||
|
|
@ -564,7 +559,6 @@ bool test_sdg(InputStream&, const SDG&, const char* ifname, const char* ofname,
|
||||||
start_testing("validity check and clear methods");
|
start_testing("validity check and clear methods");
|
||||||
end_testing("validity check and clear method");
|
end_testing("validity check and clear method");
|
||||||
|
|
||||||
delete ifname_full;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue