test/matrix_maps_test.cc
changeset 2250 b8fbffd35445
parent 2039 dacc4ce9474d
child 2260 4274224f8a7d
equal deleted inserted replaced
3:a8778e88bb60 4:b261b24244c4
    65     for (int i = 0; i < 10; ++i) {
    65     for (int i = 0; i < 10; ++i) {
    66       graph.addNode();
    66       graph.addNode();
    67     }
    67     }
    68     for (Graph::NodeIt it(graph); it != INVALID; ++it) {
    68     for (Graph::NodeIt it(graph); it != INVALID; ++it) {
    69       for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) {
    69       for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) {
    70 	int val = urandom(100);
    70 	int val = rnd[100];
    71 	matrix.set(it, jt, val);
    71 	matrix.set(it, jt, val);
    72 	check(matrix(it, jt) == val, "Wrong assign");
    72 	check(matrix(it, jt) == val, "Wrong assign");
    73 	check(matrix(it, jt) == matrixRowMap(matrix, it)[jt], "Wrong rowMap");
    73 	check(matrix(it, jt) == matrixRowMap(matrix, it)[jt], "Wrong rowMap");
    74 	check(matrix(it, jt) == matrixColMap(matrix, jt)[it], "Wrong colMap");
    74 	check(matrix(it, jt) == matrixColMap(matrix, jt)[it], "Wrong colMap");
    75       }
    75       }
   106     for (int i = 0; i < 10; ++i) {
   106     for (int i = 0; i < 10; ++i) {
   107       graph.addNode();
   107       graph.addNode();
   108     }
   108     }
   109     for (Graph::NodeIt it(graph); it != INVALID; ++it) {
   109     for (Graph::NodeIt it(graph); it != INVALID; ++it) {
   110       for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) {
   110       for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) {
   111 	int val = urandom(100);
   111 	int val = rnd[100];
   112 	matrix.set(it, jt, val);
   112 	matrix.set(it, jt, val);
   113 	check(matrix(it, jt) == val, "Wrong assign");
   113 	check(matrix(it, jt) == val, "Wrong assign");
   114 	check(matrix(jt, it) == val, "Wrong assign");
   114 	check(matrix(jt, it) == val, "Wrong assign");
   115 	check(matrix(it, jt) == matrixRowMap(matrix, it)[jt], "Wrong rowMap");
   115 	check(matrix(it, jt) == matrixRowMap(matrix, it)[jt], "Wrong rowMap");
   116 	check(matrix(it, jt) == matrixColMap(matrix, jt)[it], "Wrong colMap");
   116 	check(matrix(it, jt) == matrixColMap(matrix, jt)[it], "Wrong colMap");
   152     for (int i = 0; i < 20; ++i) {
   152     for (int i = 0; i < 20; ++i) {
   153       graph2.addEdge(Graph::NodeIt(graph2), Graph::NodeIt(graph2));
   153       graph2.addEdge(Graph::NodeIt(graph2), Graph::NodeIt(graph2));
   154     }
   154     }
   155     for (Graph::NodeIt it(graph1); it != INVALID; ++it) {
   155     for (Graph::NodeIt it(graph1); it != INVALID; ++it) {
   156       for (Graph::EdgeIt jt(graph2); jt != INVALID; ++jt) {
   156       for (Graph::EdgeIt jt(graph2); jt != INVALID; ++jt) {
   157 	int val = urandom(100);
   157 	int val = rnd[100];
   158 	matrix.set(it, jt, val);
   158 	matrix.set(it, jt, val);
   159 	check(matrix(it, jt) == val, "Wrong assign");
   159 	check(matrix(it, jt) == val, "Wrong assign");
   160 	check(matrix(it, jt) == matrixRowMap(matrix, it)[jt], "Wrong rowMap");
   160 	check(matrix(it, jt) == matrixRowMap(matrix, it)[jt], "Wrong rowMap");
   161 	check(matrix(it, jt) == matrixColMap(matrix, jt)[it], "Wrong colMap");
   161 	check(matrix(it, jt) == matrixColMap(matrix, jt)[it], "Wrong colMap");
   162       }
   162       }
   196     for (int i = 0; i < 20; ++i) {
   196     for (int i = 0; i < 20; ++i) {
   197       graph.addEdge(Graph::NodeIt(graph), Graph::NodeIt(graph));
   197       graph.addEdge(Graph::NodeIt(graph), Graph::NodeIt(graph));
   198     }
   198     }
   199     for (Graph::NodeIt it(graph); it != INVALID; ++it) {
   199     for (Graph::NodeIt it(graph); it != INVALID; ++it) {
   200       for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) {
   200       for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) {
   201 	int val = urandom(100);
   201 	int val = rnd[100];
   202 	matrix.set(it, jt, val);
   202 	matrix.set(it, jt, val);
   203 	check(matrix(it, jt) == val, "Wrong assign");
   203 	check(matrix(it, jt) == val, "Wrong assign");
   204 	check(matrix(it, jt) == matrixRowMap(matrix, it)[jt], "Wrong rowMap");
   204 	check(matrix(it, jt) == matrixRowMap(matrix, it)[jt], "Wrong rowMap");
   205 	check(matrix(it, jt) == matrixColMap(matrix, jt)[it], "Wrong colMap");
   205 	check(matrix(it, jt) == matrixColMap(matrix, jt)[it], "Wrong colMap");
   206       }
   206       }