test/matrix_maps_test.cc
changeset 1777 a70cee06ae9c
parent 1728 eb8bb91ba9e2
child 1956 a055123339d5
equal deleted inserted replaced
0:2a8c2b9f8a52 1:227ab20ede28
    51     for (Graph::NodeIt it(graph); it != INVALID; ++it) {
    51     for (Graph::NodeIt it(graph); it != INVALID; ++it) {
    52       for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) {
    52       for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) {
    53 	int val = urandom(100);
    53 	int val = urandom(100);
    54 	matrix.set(it, jt, val);
    54 	matrix.set(it, jt, val);
    55 	check(matrix(it, jt) == val, "Wrong assign");
    55 	check(matrix(it, jt) == val, "Wrong assign");
    56 	check(matrix(it, jt) == matrixColMap(matrix, it)[jt], "Wrong colMap");
    56 	check(matrix(it, jt) == matrixRowMap(matrix, it)[jt], "Wrong rowMap");
    57 	check(matrix(it, jt) == matrixRowMap(matrix, jt)[it], "Wrong rowMap");
    57 	check(matrix(it, jt) == matrixColMap(matrix, jt)[it], "Wrong colMap");
    58       }
    58       }
    59     }
    59     }
    60     const IntMatrixMap& cm = matrix;
    60     const IntMatrixMap& cm = matrix;
    61     for (Graph::NodeIt it(graph); it != INVALID; ++it) {
    61     for (Graph::NodeIt it(graph); it != INVALID; ++it) {
    62       for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) {
    62       for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) {
    63 	check(cm(it, jt) == matrixColMap(cm, it)[jt], "Wrong colMap");
    63 	check(cm(it, jt) == matrixRowMap(cm, it)[jt], "Wrong rowMap");
    64 	check(cm(it, jt) == matrixRowMap(cm, jt)[it], "Wrong rowMap");
    64 	check(cm(it, jt) == matrixColMap(cm, jt)[it], "Wrong colMap");
    65       }
    65       }
    66     }
    66     }
    67   }
    67   }
    68 
    68 
    69   { // checking MatrixMap for int
    69   { // checking MatrixMap for int
    93       for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) {
    93       for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) {
    94 	int val = urandom(100);
    94 	int val = urandom(100);
    95 	matrix.set(it, jt, val);
    95 	matrix.set(it, jt, val);
    96 	check(matrix(it, jt) == val, "Wrong assign");
    96 	check(matrix(it, jt) == val, "Wrong assign");
    97 	check(matrix(jt, it) == val, "Wrong assign");
    97 	check(matrix(jt, it) == val, "Wrong assign");
    98 	check(matrix(it, jt) == matrixColMap(matrix, it)[jt], "Wrong colMap");
    98 	check(matrix(it, jt) == matrixRowMap(matrix, it)[jt], "Wrong rowMap");
    99 	check(matrix(it, jt) == matrixRowMap(matrix, jt)[it], "Wrong rowMap");
    99 	check(matrix(it, jt) == matrixColMap(matrix, jt)[it], "Wrong colMap");
   100       }
   100       }
   101     }
   101     }
   102     const IntMatrixMap& cm = matrix;
   102     const IntMatrixMap& cm = matrix;
   103     for (Graph::NodeIt it(graph); it != INVALID; ++it) {
   103     for (Graph::NodeIt it(graph); it != INVALID; ++it) {
   104       for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) {
   104       for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) {
   105 	check(cm(it, jt) == matrixColMap(cm, it)[jt], "Wrong colMap");
   105 	check(cm(it, jt) == matrixRowMap(cm, it)[jt], "Wrong rowMap");
   106 	check(cm(it, jt) == matrixRowMap(cm, jt)[it], "Wrong rowMap");
   106 	check(cm(it, jt) == matrixColMap(cm, jt)[it], "Wrong colMap");
   107       }
   107       }
   108     }
   108     }
   109   }
   109   }
   110 
   110 
   111   std::cout << __FILE__ ": All tests passed.\n";
   111   std::cout << __FILE__ ": All tests passed.\n";