diff -r 0c7d717b9538 -r eb8bb91ba9e2 test/matrix_maps_test.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/matrix_maps_test.cc Fri Oct 14 11:03:40 2005 +0000 @@ -0,0 +1,114 @@ +// -*- c++ -*- + +#include +#include + +#include + +#include +#include +#include + +#include + +#include + +#include "test_tools.h" +#include "graph_test.h" +#include "map_test.h" + + +using namespace lemon; +using namespace lemon::concept; + +int main() { + typedef SmartGraph Graph; + typedef Graph::Node Node; + + { // checking MatrixMap for int + typedef DynamicMatrixMap IntMatrixMap; + checkConcept, + IntMatrixMap>(); + + } + + { // checking MatrixMap for bool + typedef DynamicMatrixMap BoolMatrixMap; + checkConcept, + BoolMatrixMap>(); + + } + + { + Graph graph; + typedef DynamicMatrixMap IntMatrixMap; + IntMatrixMap matrix(graph); + for (int i = 0; i < 10; ++i) { + graph.addNode(); + } + for (Graph::NodeIt it(graph); it != INVALID; ++it) { + for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) { + int val = urandom(100); + matrix.set(it, jt, val); + check(matrix(it, jt) == val, "Wrong assign"); + check(matrix(it, jt) == matrixColMap(matrix, it)[jt], "Wrong colMap"); + check(matrix(it, jt) == matrixRowMap(matrix, jt)[it], "Wrong rowMap"); + } + } + const IntMatrixMap& cm = matrix; + for (Graph::NodeIt it(graph); it != INVALID; ++it) { + for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) { + check(cm(it, jt) == matrixColMap(cm, it)[jt], "Wrong colMap"); + check(cm(it, jt) == matrixRowMap(cm, jt)[it], "Wrong rowMap"); + } + } + } + + { // checking MatrixMap for int + typedef DynamicSymMatrixMap IntMatrixMap; + checkConcept, + IntMatrixMap>(); + + } + + { // checking MatrixMap for bool + typedef DynamicSymMatrixMap BoolMatrixMap; + checkConcept, + BoolMatrixMap>(); + + } + + { + Graph graph; + typedef DynamicSymMatrixMap IntMatrixMap; + IntMatrixMap matrix(graph); + for (int i = 0; i < 10; ++i) { + graph.addNode(); + } + for (Graph::NodeIt it(graph); it != INVALID; ++it) { + for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) { + int val = urandom(100); + matrix.set(it, jt, val); + check(matrix(it, jt) == val, "Wrong assign"); + check(matrix(jt, it) == val, "Wrong assign"); + check(matrix(it, jt) == matrixColMap(matrix, it)[jt], "Wrong colMap"); + check(matrix(it, jt) == matrixRowMap(matrix, jt)[it], "Wrong rowMap"); + } + } + const IntMatrixMap& cm = matrix; + for (Graph::NodeIt it(graph); it != INVALID; ++it) { + for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) { + check(cm(it, jt) == matrixColMap(cm, it)[jt], "Wrong colMap"); + check(cm(it, jt) == matrixRowMap(cm, jt)[it], "Wrong rowMap"); + } + } + } + + std::cout << __FILE__ ": All tests passed.\n"; + + return 0; +}