COIN-OR::LEMON - Graph Library

Changeset 858:acc83957ee4a in lemon-0.x for src/test/preflow_test.cc


Ignore:
Timestamp:
09/15/04 16:25:44 (20 years ago)
Author:
Mihaly Barasz
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1158
Message:

Handling strings with std::string
Do not segfault if srcdir env. variable is not set.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/test/preflow_test.cc

    r855 r858  
    11#include <fstream>
     2#include <string>
     3
    24#include "test_tools.h"
    35#include <hugo/smart_graph.h>
     
    68#include <hugo/skeletons/graph.h>
    79#include <hugo/skeletons/maps.h>
    8 
    9 #include <string.h>
    1010
    1111using namespace hugo;
     
    7070  typedef Preflow<Graph, int> PType;
    7171
    72   char *f_name;
     72  string f_name;
     73  if( getenv("srcdir") ) {
     74    f_name = string(getenv("srcdir")) + "/preflow_graph.inp";
     75  }
     76  else {
     77    f_name = "preflow_graph.inp";
     78  }
    7379 
    74   f_name=new char[strlen(getenv("srcdir"))+50];
    75   strcpy(f_name,getenv("srcdir"));
    76   strcat(f_name,"/preflow_graph.inp");
     80  std::ifstream file(f_name.c_str());
    7781 
    78   std::ifstream file(f_name);
    79  
    80   check(file,"Input file '" << f_name << "' not found.");
    81  
    82   delete [] f_name;
     82  check(file, "Input file '" << f_name << "' not found.");
    8383 
    8484  Graph G;
     
    181181        "The max flow value or the three min cut values are incorrect.");
    182182}
    183 
    184 
    185 
Note: See TracChangeset for help on using the changeset viewer.