1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
3 * This file is a part of LEMON, a generic C++ optimization library.
5 * Copyright (C) 2003-2011
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
19 #include <lemon/list_graph.h>
20 #include <lemon/lgf_reader.h>
21 #include "test_tools.h"
23 using namespace lemon;
38 char test_lgf_nomap[] =
47 char test_lgf_bad1[] =
56 char test_lgf_bad2[] =
70 ListDigraph::Node s,t;
71 ListDigraph::ArcMap<int> label(d);
72 std::istringstream input(test_lgf);
73 digraphReader(d, input).
76 arcMap("label", label).
78 check(countNodes(d) == 2,"There should be 2 nodes");
79 check(countArcs(d) == 2,"There should be 2 arcs");
84 ListGraph::EdgeMap<int> label(g);
85 std::istringstream input(test_lgf);
86 graphReader(g, input).
89 edgeMap("label", label).
91 check(countNodes(g) == 2,"There should be 2 nodes");
92 check(countEdges(g) == 2,"There should be 2 arcs");
97 std::istringstream input(test_lgf_nomap);
98 digraphReader(d, input).
100 check(countNodes(d) == 2,"There should be 2 nodes");
101 check(countArcs(d) == 1,"There should be 1 arc");
105 std::istringstream input(test_lgf_nomap);
106 graphReader(g, input).
108 check(countNodes(g) == 2,"There should be 2 nodes");
109 check(countEdges(g) == 1,"There should be 1 edge");
114 std::istringstream input(test_lgf_bad1);
117 digraphReader(d, input).
120 catch (FormatError& error)
124 check(ok,"FormatError exception should have occured");
128 std::istringstream input(test_lgf_bad1);
131 graphReader(g, input).
134 catch (FormatError& error)
138 check(ok,"FormatError exception should have occured");
143 std::istringstream input(test_lgf_bad2);
146 digraphReader(d, input).
149 catch (FormatError& error)
153 check(ok,"FormatError exception should have occured");
157 std::istringstream input(test_lgf_bad2);
160 graphReader(g, input).
163 catch (FormatError& error)
167 check(ok,"FormatError exception should have occured");