diff --git a/Segment_Delaunay_graph_2/test/Segment_Delaunay_graph_2/include/test.h b/Segment_Delaunay_graph_2/test/Segment_Delaunay_graph_2/include/test.h index 3038ef5215c..14d2ec7152a 100644 --- a/Segment_Delaunay_graph_2/test/Segment_Delaunay_graph_2/include/test.h +++ b/Segment_Delaunay_graph_2/test/Segment_Delaunay_graph_2/include/test.h @@ -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 -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 ); diff --git a/Segment_Delaunay_graph_2/test/Segment_Delaunay_graph_2/include/test_types.h b/Segment_Delaunay_graph_2/test/Segment_Delaunay_graph_2/include/test_types.h index 09ea811c3af..e124868718e 100644 --- a/Segment_Delaunay_graph_2/test/Segment_Delaunay_graph_2/include/test_types.h +++ b/Segment_Delaunay_graph_2/test/Segment_Delaunay_graph_2/include/test_types.h @@ -10,6 +10,7 @@ #include #include #include +#include #include "IO/Null_output_stream.h" #include "IO/io_aux.h" @@ -72,7 +73,7 @@ struct Level_finder< Segment_Delaunay_graph_2 > //======================================================================== template -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(); diff --git a/Segment_Delaunay_graph_Linf_2/test/Segment_Delaunay_graph_Linf_2/include/test.h b/Segment_Delaunay_graph_Linf_2/test/Segment_Delaunay_graph_Linf_2/include/test.h index 3038ef5215c..14d2ec7152a 100644 --- a/Segment_Delaunay_graph_Linf_2/test/Segment_Delaunay_graph_Linf_2/include/test.h +++ b/Segment_Delaunay_graph_Linf_2/test/Segment_Delaunay_graph_Linf_2/include/test.h @@ -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 -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 ); diff --git a/Segment_Delaunay_graph_Linf_2/test/Segment_Delaunay_graph_Linf_2/include/test_types.h b/Segment_Delaunay_graph_Linf_2/test/Segment_Delaunay_graph_Linf_2/include/test_types.h index 73e078423e4..ae24ecfe483 100644 --- a/Segment_Delaunay_graph_Linf_2/test/Segment_Delaunay_graph_Linf_2/include/test_types.h +++ b/Segment_Delaunay_graph_Linf_2/test/Segment_Delaunay_graph_Linf_2/include/test_types.h @@ -10,6 +10,7 @@ #include #include #include +#include #include "IO/Null_output_stream.h" #include "IO/io_aux.h" @@ -72,7 +73,7 @@ struct Level_finder< Segment_Delaunay_graph_Linf_2 > //======================================================================== template -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();