20#include <test/csf/Digraph.h>
21#include <xrpl/beast/unit_test.h>
36 using Graph = Digraph<char, std::string>;
39 BEAST_EXPECT(!graph.connected(
'a',
'b'));
40 BEAST_EXPECT(!graph.edge(
'a',
'b'));
41 BEAST_EXPECT(!graph.disconnect(
'a',
'b'));
43 BEAST_EXPECT(graph.connect(
'a',
'b',
"foobar"));
44 BEAST_EXPECT(graph.connected(
'a',
'b'));
45 BEAST_EXPECT(*graph.edge(
'a',
'b') ==
"foobar");
47 BEAST_EXPECT(!graph.connect(
'a',
'b',
"repeat"));
48 BEAST_EXPECT(graph.disconnect(
'a',
'b'));
49 BEAST_EXPECT(graph.connect(
'a',
'b',
"repeat"));
50 BEAST_EXPECT(graph.connected(
'a',
'b'));
51 BEAST_EXPECT(*graph.edge(
'a',
'b') ==
"repeat");
53 BEAST_EXPECT(graph.connect(
'a',
'c',
"tree"));
58 for (
auto const& edge : graph.outEdges(
'a'))
66 BEAST_EXPECT(edges == expected);
67 BEAST_EXPECT(graph.outDegree(
'a') == expected.
size());
70 BEAST_EXPECT(graph.outEdges(
'r').size() == 0);
71 BEAST_EXPECT(graph.outDegree(
'r') == 0);
72 BEAST_EXPECT(graph.outDegree(
'c') == 0);
75 BEAST_EXPECT(graph.outVertices().size() == 1);
78 BEAST_EXPECT((graph.outVertices(
'a') == expected));
79 BEAST_EXPECT(graph.outVertices(
'b').size() == 0);
80 BEAST_EXPECT(graph.outVertices(
'c').size() == 0);
81 BEAST_EXPECT(graph.outVertices(
'r').size() == 0);
84 graph.saveDot(ss, [](
char v) {
return v; });
90 BEAST_EXPECT(ss.
str() == expectedDot);
94BEAST_DEFINE_TESTSUITE(Digraph, test,
ripple);
void run() override
Runs the suite.
T emplace_back(T... args)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.