1 #define LOG_TAG "hidl_test"
2
3 #include <log/log.h>
4
5 #include "PointerHelper.h"
6
7 namespace android {
8
simpleGraph(IGraph::Graph & g)9 void simpleGraph(IGraph::Graph& g) {
10 g.nodes.resize(2);
11 g.edges.resize(1);
12 g.nodes[0].data = 10;
13 g.nodes[1].data = 20;
14 g.edges[0].left = &g.nodes[0];
15 g.edges[0].right = &g.nodes[1];
16 }
17
isSimpleGraph(const IGraph::Graph & g)18 bool isSimpleGraph(const IGraph::Graph &g) {
19 if(g.nodes.size() != 2) return false;
20 if(g.edges.size() != 1) return false;
21 if(g.nodes[0].data != 10) return false;
22 if(g.nodes[1].data != 20) return false;
23 if(g.edges[0].left != &g.nodes[0]) return false;
24 if(g.edges[0].right != &g.nodes[1]) return false;
25 return true;
26 }
27
logSimpleGraph(const char * prefix,const IGraph::Graph & g)28 void logSimpleGraph(const char *prefix, const IGraph::Graph& g) {
29 ALOGI("%s Graph %p, %d nodes, %d edges", prefix, &g, (int)g.nodes.size(), (int)g.edges.size());
30 std::ostringstream os;
31 for(size_t i = 0; i < g.nodes.size(); i++)
32 os << &g.nodes[i] << " = " << g.nodes[i].data << ", ";
33 ALOGI("%s Nodes: [%s]", prefix, os.str().c_str());
34 os.str("");
35 os.clear();
36 for(size_t i = 0; i < g.edges.size(); i++)
37 os << g.edges[i].left << " -> " << g.edges[i].right << ", ";
38 ALOGI("%s Edges: [%s]", prefix, os.str().c_str());
39 }
40 } // namespace android
41