test/lgf_test.cc
branch1.0
changeset 427 c59bdcc8e33e
parent 422 54464584b157
equal deleted inserted replaced
0:2c4a17d48af5 1:c9f3c05aab34
    61   "@arcs\n"
    61   "@arcs\n"
    62   "     label -\n"
    62   "     label -\n"
    63   "0 1\n";
    63   "0 1\n";
    64 
    64 
    65 
    65 
    66 int main() 
    66 int main()
    67 {
    67 {
    68   {
    68   {
    69     ListDigraph d; 
    69     ListDigraph d;
    70     ListDigraph::Node s,t;
    70     ListDigraph::Node s,t;
    71     ListDigraph::ArcMap<int> label(d);
    71     ListDigraph::ArcMap<int> label(d);
    72     std::istringstream input(test_lgf);
    72     std::istringstream input(test_lgf);
    73     digraphReader(d, input).
    73     digraphReader(d, input).
    74       node("source", s).
    74       node("source", s).
    91     check(countNodes(g) == 2,"There should be 2 nodes");
    91     check(countNodes(g) == 2,"There should be 2 nodes");
    92     check(countEdges(g) == 2,"There should be 2 arcs");
    92     check(countEdges(g) == 2,"There should be 2 arcs");
    93   }
    93   }
    94 
    94 
    95   {
    95   {
    96     ListDigraph d; 
    96     ListDigraph d;
    97     std::istringstream input(test_lgf_nomap);
    97     std::istringstream input(test_lgf_nomap);
    98     digraphReader(d, input).
    98     digraphReader(d, input).
    99       run();
    99       run();
   100     check(countNodes(d) == 2,"There should be 2 nodes");
   100     check(countNodes(d) == 2,"There should be 2 nodes");
   101     check(countArcs(d) == 1,"There should be 1 arc");
   101     check(countArcs(d) == 1,"There should be 1 arc");
   108     check(countNodes(g) == 2,"There should be 2 nodes");
   108     check(countNodes(g) == 2,"There should be 2 nodes");
   109     check(countEdges(g) == 1,"There should be 1 edge");
   109     check(countEdges(g) == 1,"There should be 1 edge");
   110   }
   110   }
   111 
   111 
   112   {
   112   {
   113     ListDigraph d; 
   113     ListDigraph d;
   114     std::istringstream input(test_lgf_bad1);
   114     std::istringstream input(test_lgf_bad1);
   115     bool ok=false;
   115     bool ok=false;
   116     try {
   116     try {
   117       digraphReader(d, input).
   117       digraphReader(d, input).
   118         run();
   118         run();
   119     }
   119     }
   120     catch (FormatError& error) 
   120     catch (FormatError& error)
   121       {
   121       {
   122         ok = true;
   122         ok = true;
   123       }
   123       }
   124     check(ok,"FormatError exception should have occured");
   124     check(ok,"FormatError exception should have occured");
   125   }
   125   }
   137       }
   137       }
   138     check(ok,"FormatError exception should have occured");
   138     check(ok,"FormatError exception should have occured");
   139   }
   139   }
   140 
   140 
   141   {
   141   {
   142     ListDigraph d; 
   142     ListDigraph d;
   143     std::istringstream input(test_lgf_bad2);
   143     std::istringstream input(test_lgf_bad2);
   144     bool ok=false;
   144     bool ok=false;
   145     try {
   145     try {
   146       digraphReader(d, input).
   146       digraphReader(d, input).
   147         run();
   147         run();