Segment_delaunnay_graph: fstream -> sstream

This commit is contained in:
Andreas Fabri 2022-01-21 14:57:25 +00:00
parent ad08f020b6
commit 88833ad0b4
4 changed files with 29 additions and 30 deletions

View File

@ -11,7 +11,7 @@ bool test_x(InputStream& is, const char* ifname, bool test_remove = true)
{
SDG2 sdg;
std::cout << "Testing data from file: " << ifname << std::endl;
return test_base(is, sdg, ifname, "sdg.tmp", test_remove);
return test_base(is, sdg, ifname, test_remove);
}
@ -20,7 +20,7 @@ bool test_no_x(InputStream& is, const char* ifname, bool test_remove = true)
{
SDG2_wi sdg;
std::cout << "Testing data from file: " << ifname << std::endl;
return test_base(is, sdg, ifname, "sdg_wi.tmp", test_remove);
return test_base(is, sdg, ifname, test_remove);
}
//=====================================================================
@ -30,7 +30,7 @@ bool test_hierarchy_x(InputStream& is, const char* ifname, bool test_remove = tr
{
SDG2 sdg;
std::cout << "Testing data from file: " << ifname << std::endl;
return test_base(is, sdg, ifname, "sdgh.tmp", test_remove);
return test_base(is, sdg, ifname, test_remove);
}
@ -39,7 +39,7 @@ bool test_hierarchy_no_x(InputStream& is, const char* ifname, bool test_remove =
{
SDG2_wi sdg;
std::cout << "Testing data from file: " << ifname << std::endl;
return test_base(is, sdg, ifname, "sdgh_wi.tmp", test_remove);
return test_base(is, sdg, ifname, test_remove);
}
@ -47,12 +47,12 @@ bool test_hierarchy_no_x(InputStream& is, const char* ifname, bool test_remove =
template<class SDG, class InputStream>
bool test_base(InputStream&, const SDG& sdg, const char* ifname, const char* ofname,
bool test_base(InputStream&, const SDG& sdg, const char* ifname,
bool test_remove)
{
print_separator();
bool types_ok = CGAL::test_sdg(std::cin, sdg, ifname, ofname, test_remove);
bool types_ok = CGAL::test_sdg(std::cin, sdg, ifname, test_remove);
assert_no_warning( types_ok );

View File

@ -10,6 +10,7 @@
#include <algorithm>
#include <cassert>
#include <string>
#include <sstream>
#include "IO/Null_output_stream.h"
#include "IO/io_aux.h"
@ -72,7 +73,7 @@ struct Level_finder< Segment_Delaunay_graph_2<Gt,SDGDS,LTag> >
//========================================================================
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,
bool test_remove)
{
typedef SDG SDG2;
@ -525,19 +526,17 @@ bool test_sdg(InputStream&, const SDG&, const char* ifname, const char* ofname,
size_type npc1 = sdg.point_container().size();
size_type nv1 = sdg.number_of_vertices();
std::ofstream ofs(ofname);
assert( ofs );
sdg.file_output(ofs);
std::ostringstream oss;
sdg.file_output(oss);
assert( sdg.is_valid() );
ofs.close();
oss.flush();
std::string input = oss.str();
sdg.clear();
std::ifstream ifs(ofname);
assert( ifs );
sdg.file_input(ifs);
std::istringstream iss(input);
sdg.file_input(iss);
assert( sdg.is_valid() );
ifs.close();
size_type nisc2 = sdg.number_of_input_sites();
size_type npc2 = sdg.point_container().size();

View File

@ -11,7 +11,7 @@ bool test_x(InputStream& is, const char* ifname, bool test_remove = true)
{
SDG2 sdg;
std::cout << "Testing data from file: " << ifname << std::endl;
return test_base(is, sdg, ifname, "sdg.tmp", test_remove);
return test_base(is, sdg, ifname, test_remove);
}
@ -20,7 +20,7 @@ bool test_no_x(InputStream& is, const char* ifname, bool test_remove = true)
{
SDG2_wi sdg;
std::cout << "Testing data from file: " << ifname << std::endl;
return test_base(is, sdg, ifname, "sdg_wi.tmp", test_remove);
return test_base(is, sdg, ifname, test_remove);
}
//=====================================================================
@ -30,7 +30,7 @@ bool test_hierarchy_x(InputStream& is, const char* ifname, bool test_remove = tr
{
SDG2 sdg;
std::cout << "Testing data from file: " << ifname << std::endl;
return test_base(is, sdg, ifname, "sdgh.tmp", test_remove);
return test_base(is, sdg, ifname, test_remove);
}
@ -39,7 +39,7 @@ bool test_hierarchy_no_x(InputStream& is, const char* ifname, bool test_remove =
{
SDG2_wi sdg;
std::cout << "Testing data from file: " << ifname << std::endl;
return test_base(is, sdg, ifname, "sdgh_wi.tmp", test_remove);
return test_base(is, sdg, ifname, test_remove);
}
@ -47,12 +47,12 @@ bool test_hierarchy_no_x(InputStream& is, const char* ifname, bool test_remove =
template<class SDG, class InputStream>
bool test_base(InputStream&, const SDG& sdg, const char* ifname, const char* ofname,
bool test_base(InputStream&, const SDG& sdg, const char* ifname,
bool test_remove)
{
print_separator();
bool types_ok = CGAL::test_sdg(std::cin, sdg, ifname, ofname, test_remove);
bool types_ok = CGAL::test_sdg(std::cin, sdg, ifname, test_remove);
assert_no_warning( types_ok );

View File

@ -10,6 +10,7 @@
#include <algorithm>
#include <cassert>
#include <string>
#include <sstream>
#include "IO/Null_output_stream.h"
#include "IO/io_aux.h"
@ -72,7 +73,7 @@ struct Level_finder< Segment_Delaunay_graph_Linf_2<Gt,SDGDS,LTag> >
//========================================================================
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,
bool test_remove)
{
typedef SDG SDG2;
@ -524,19 +525,18 @@ bool test_sdg(InputStream&, const SDG&, const char* ifname, const char* ofname,
size_type npc1 = sdg.point_container().size();
size_type nv1 = sdg.number_of_vertices();
std::ofstream ofs(ofname);
assert( ofs );
sdg.file_output(ofs);
std::ostringstream oss;
sdg.file_output(oss);
assert( sdg.is_valid() );
ofs.close();
oss.flush();
std::string input = oss.str();
sdg.clear();
std::ifstream ifs(ofname);
assert( ifs );
sdg.file_input(ifs);
std::istringstream iss(input);
sdg.file_input(iss);
assert( sdg.is_valid() );
ifs.close();
size_type nisc2 = sdg.number_of_input_sites();
size_type npc2 = sdg.point_container().size();