COIN-OR::LEMON - Graph Library

Changeset 959:17e36e175725 in lemon-main for test


Ignore:
Timestamp:
12/20/11 17:35:45 (13 years ago)
Author:
Alpar Juttner <alpar@…>
Branch:
default
Parents:
957:2eebc8f7dca5 (diff), 954:b96574ff36ec (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Phase:
public
Message:

Merge

Location:
test
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • test/CMakeLists.txt

    r949 r959  
    11INCLUDE_DIRECTORIES(
    2   ${CMAKE_SOURCE_DIR}
     2  ${PROJECT_SOURCE_DIR}
    33  ${PROJECT_BINARY_DIR}
    44)
    55
    6 LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/lemon)
     6LINK_DIRECTORIES(
     7  ${PROJECT_BINARY_DIR}/lemon
     8)
     9
     10SET(TEST_WITH_VALGRIND "NO" CACHE STRING
     11  "Run the test with valgrind (YES/NO).")
     12SET(VALGRIND_FLAGS "" CACHE STRING "Valgrind flags used by the tests.")
    713
    814SET(TESTS
     15  adaptors_test
    916  bfs_test
     17  circulation_test
     18  connectivity_test
    1019  counter_test
    1120  dfs_test
     
    1322  dijkstra_test
    1423  dim_test
     24  edge_set_test
    1525  error_test
     26  euler_test
     27  gomory_hu_test
    1628  graph_copy_test
    1729  graph_test
    1830  graph_utils_test
     31  hao_orlin_test
    1932  heap_test
    2033  kruskal_test
    2134  lgf_test
    2235  maps_test
     36  matching_test
     37  min_cost_arborescence_test
     38  min_cost_flow_test
     39  path_test
     40  preflow_test
     41  radix_sort_test
    2342  random_test
    24   path_test
     43  suurballe_test
    2544  time_measure_test
    26   unionfind_test)
     45  unionfind_test
     46)
     47
     48IF(LEMON_HAVE_LP)
     49  IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
     50    ADD_EXECUTABLE(lp_test lp_test.cc)
     51  ELSE()
     52    ADD_EXECUTABLE(lp_test EXCLUDE_FROM_ALL lp_test.cc)
     53  ENDIF()
     54
     55  SET(LP_TEST_LIBS lemon)
     56
     57  IF(LEMON_HAVE_GLPK)
     58    SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${GLPK_LIBRARIES})
     59  ENDIF()
     60  IF(LEMON_HAVE_CPLEX)
     61    SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${CPLEX_LIBRARIES})
     62  ENDIF()
     63  IF(LEMON_HAVE_CLP)
     64    SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${COIN_CLP_LIBRARIES})
     65  ENDIF()
     66
     67  TARGET_LINK_LIBRARIES(lp_test ${LP_TEST_LIBS})
     68  ADD_TEST(lp_test lp_test)
     69  ADD_DEPENDENCIES(check lp_test)
     70
     71  IF(WIN32 AND LEMON_HAVE_GLPK)
     72    GET_TARGET_PROPERTY(TARGET_LOC lp_test LOCATION)
     73    GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH)
     74    ADD_CUSTOM_COMMAND(TARGET lp_test POST_BUILD
     75      COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/glpk.dll ${TARGET_PATH}
     76      COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/libltdl3.dll ${TARGET_PATH}
     77      COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH}
     78    )
     79  ENDIF()
     80
     81  IF(WIN32 AND LEMON_HAVE_CPLEX)
     82    GET_TARGET_PROPERTY(TARGET_LOC lp_test LOCATION)
     83    GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH)
     84    ADD_CUSTOM_COMMAND(TARGET lp_test POST_BUILD
     85      COMMAND ${CMAKE_COMMAND} -E copy ${CPLEX_BIN_DIR}/cplex91.dll ${TARGET_PATH}
     86    )
     87  ENDIF()
     88ENDIF()
     89
     90IF(LEMON_HAVE_MIP)
     91  IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
     92    ADD_EXECUTABLE(mip_test mip_test.cc)
     93  ELSE()
     94    ADD_EXECUTABLE(mip_test EXCLUDE_FROM_ALL mip_test.cc)
     95  ENDIF()
     96
     97  SET(MIP_TEST_LIBS lemon)
     98
     99  IF(LEMON_HAVE_GLPK)
     100    SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${GLPK_LIBRARIES})
     101  ENDIF()
     102  IF(LEMON_HAVE_CPLEX)
     103    SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${CPLEX_LIBRARIES})
     104  ENDIF()
     105  IF(LEMON_HAVE_CBC)
     106    SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${COIN_CBC_LIBRARIES})
     107  ENDIF()
     108
     109  TARGET_LINK_LIBRARIES(mip_test ${MIP_TEST_LIBS})
     110  ADD_TEST(mip_test mip_test)
     111  ADD_DEPENDENCIES(check mip_test)
     112
     113  IF(WIN32 AND LEMON_HAVE_GLPK)
     114    GET_TARGET_PROPERTY(TARGET_LOC mip_test LOCATION)
     115    GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH)
     116    ADD_CUSTOM_COMMAND(TARGET mip_test POST_BUILD
     117      COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/glpk.dll ${TARGET_PATH}
     118      COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/libltdl3.dll ${TARGET_PATH}
     119      COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH}
     120    )
     121  ENDIF()
     122
     123  IF(WIN32 AND LEMON_HAVE_CPLEX)
     124    GET_TARGET_PROPERTY(TARGET_LOC mip_test LOCATION)
     125    GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH)
     126    ADD_CUSTOM_COMMAND(TARGET mip_test POST_BUILD
     127      COMMAND ${CMAKE_COMMAND} -E copy ${CPLEX_BIN_DIR}/cplex91.dll ${TARGET_PATH}
     128    )
     129  ENDIF()
     130ENDIF()
    27131
    28132FOREACH(TEST_NAME ${TESTS})
    29   ADD_EXECUTABLE(${TEST_NAME} ${TEST_NAME}.cc)
     133  IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
     134    ADD_EXECUTABLE(${TEST_NAME} ${TEST_NAME}.cc)
     135  ELSE()
     136    ADD_EXECUTABLE(${TEST_NAME} EXCLUDE_FROM_ALL ${TEST_NAME}.cc)
     137  ENDIF()
    30138  TARGET_LINK_LIBRARIES(${TEST_NAME} lemon)
    31   ADD_TEST(${TEST_NAME} ${TEST_NAME})
    32 ENDFOREACH(TEST_NAME)
     139    IF(TEST_WITH_VALGRIND)
     140      ADD_TEST(${TEST_NAME}
     141        valgrind --error-exitcode=1 ${VALGRIND_FLAGS}
     142        ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME} )
     143    ELSE()
     144      ADD_TEST(${TEST_NAME} ${TEST_NAME})
     145    ENDIF()
     146  ADD_DEPENDENCIES(check ${TEST_NAME})
     147ENDFOREACH()
  • test/CMakeLists.txt

    r945 r959  
    3232  heap_test
    3333  kruskal_test
     34  lgf_test
    3435  maps_test
    3536  matching_test
  • test/Makefile.am

    r949 r959  
    44noinst_HEADERS += \
    55        test/graph_test.h \
    6         test/test_tools.h
     6        test/test_tools.h
    77
    88check_PROGRAMS += \
     9        test/adaptors_test \
    910        test/bfs_test \
    10         test/counter_test \
     11        test/circulation_test \
     12        test/connectivity_test \
     13        test/counter_test \
    1114        test/dfs_test \
    1215        test/digraph_test \
    1316        test/dijkstra_test \
    14         test/dim_test \
     17        test/dim_test \
     18        test/edge_set_test \
    1519        test/error_test \
     20        test/euler_test \
     21        test/gomory_hu_test \
    1622        test/graph_copy_test \
    1723        test/graph_test \
    1824        test/graph_utils_test \
     25        test/hao_orlin_test \
    1926        test/heap_test \
    2027        test/kruskal_test \
    2128        test/lgf_test \
    22         test/maps_test \
    23         test/random_test \
    24         test/path_test \
    25         test/test_tools_fail \
    26         test/test_tools_pass \
    27         test/time_measure_test \
     29        test/maps_test \
     30        test/matching_test \
     31        test/min_cost_arborescence_test \
     32        test/min_cost_flow_test \
     33        test/path_test \
     34        test/preflow_test \
     35        test/radix_sort_test \
     36        test/random_test \
     37        test/suurballe_test \
     38        test/test_tools_fail \
     39        test/test_tools_pass \
     40        test/time_measure_test \
    2841        test/unionfind_test
     42
     43test_test_tools_pass_DEPENDENCIES = demo
     44
     45if HAVE_LP
     46check_PROGRAMS += test/lp_test
     47endif HAVE_LP
     48if HAVE_MIP
     49check_PROGRAMS += test/mip_test
     50endif HAVE_MIP
    2951
    3052TESTS += $(check_PROGRAMS)
    3153XFAIL_TESTS += test/test_tools_fail$(EXEEXT)
    3254
     55test_adaptors_test_SOURCES = test/adaptors_test.cc
    3356test_bfs_test_SOURCES = test/bfs_test.cc
     57test_circulation_test_SOURCES = test/circulation_test.cc
    3458test_counter_test_SOURCES = test/counter_test.cc
     59test_connectivity_test_SOURCES = test/connectivity_test.cc
    3560test_dfs_test_SOURCES = test/dfs_test.cc
    3661test_digraph_test_SOURCES = test/digraph_test.cc
    3762test_dijkstra_test_SOURCES = test/dijkstra_test.cc
    3863test_dim_test_SOURCES = test/dim_test.cc
     64test_edge_set_test_SOURCES = test/edge_set_test.cc
    3965test_error_test_SOURCES = test/error_test.cc
     66test_euler_test_SOURCES = test/euler_test.cc
     67test_gomory_hu_test_SOURCES = test/gomory_hu_test.cc
    4068test_graph_copy_test_SOURCES = test/graph_copy_test.cc
    4169test_graph_test_SOURCES = test/graph_test.cc
     
    4371test_heap_test_SOURCES = test/heap_test.cc
    4472test_kruskal_test_SOURCES = test/kruskal_test.cc
     73test_hao_orlin_test_SOURCES = test/hao_orlin_test.cc
    4574test_lgf_test_SOURCES = test/lgf_test.cc
     75test_lp_test_SOURCES = test/lp_test.cc
    4676test_maps_test_SOURCES = test/maps_test.cc
     77test_mip_test_SOURCES = test/mip_test.cc
     78test_matching_test_SOURCES = test/matching_test.cc
     79test_min_cost_arborescence_test_SOURCES = test/min_cost_arborescence_test.cc
     80test_min_cost_flow_test_SOURCES = test/min_cost_flow_test.cc
    4781test_path_test_SOURCES = test/path_test.cc
     82test_preflow_test_SOURCES = test/preflow_test.cc
     83test_radix_sort_test_SOURCES = test/radix_sort_test.cc
     84test_suurballe_test_SOURCES = test/suurballe_test.cc
    4885test_random_test_SOURCES = test/random_test.cc
    4986test_test_tools_fail_SOURCES = test/test_tools_fail.cc
  • test/Makefile.am

    r649 r959  
    2626        test/heap_test \
    2727        test/kruskal_test \
     28        test/lgf_test \
    2829        test/maps_test \
    2930        test/matching_test \
     
    7172test_kruskal_test_SOURCES = test/kruskal_test.cc
    7273test_hao_orlin_test_SOURCES = test/hao_orlin_test.cc
     74test_lgf_test_SOURCES = test/lgf_test.cc
    7375test_lp_test_SOURCES = test/lp_test.cc
    7476test_maps_test_SOURCES = test/maps_test.cc
  • test/dfs_test.cc

    r906 r959  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    6666  Node s, t;
    6767  Arc e;
    68   int l;
     68  int l, i;
    6969  bool b;
    7070  DType::DistMap d(G);
    7171  DType::PredMap p(G);
    7272  Path<Digraph> pp;
     73  concepts::ReadMap<Arc,bool> am;
    7374
    7475  {
    7576    DType dfs_test(G);
     77    const DType& const_dfs_test = dfs_test;
    7678
    7779    dfs_test.run(s);
     
    7981    dfs_test.run();
    8082
    81     l  = dfs_test.dist(t);
    82     e  = dfs_test.predArc(t);
    83     s  = dfs_test.predNode(t);
    84     b  = dfs_test.reached(t);
    85     d  = dfs_test.distMap();
    86     p  = dfs_test.predMap();
    87     pp = dfs_test.path(t);
     83    dfs_test.init();
     84    dfs_test.addSource(s);
     85    e = dfs_test.processNextArc();
     86    e = const_dfs_test.nextArc();
     87    b = const_dfs_test.emptyQueue();
     88    i = const_dfs_test.queueSize();
     89   
     90    dfs_test.start();
     91    dfs_test.start(t);
     92    dfs_test.start(am);
     93
     94    l  = const_dfs_test.dist(t);
     95    e  = const_dfs_test.predArc(t);
     96    s  = const_dfs_test.predNode(t);
     97    b  = const_dfs_test.reached(t);
     98    d  = const_dfs_test.distMap();
     99    p  = const_dfs_test.predMap();
     100    pp = const_dfs_test.path(t);
    88101  }
    89102  {
     
    92105      ::SetDistMap<concepts::ReadWriteMap<Node,int> >
    93106      ::SetReachedMap<concepts::ReadWriteMap<Node,bool> >
     107      ::SetStandardProcessedMap
    94108      ::SetProcessedMap<concepts::WriteMap<Node,bool> >
    95       ::SetStandardProcessedMap
    96109      ::Create dfs_test(G);
     110
     111    concepts::ReadWriteMap<Node,Arc> pred_map;
     112    concepts::ReadWriteMap<Node,int> dist_map;
     113    concepts::ReadWriteMap<Node,bool> reached_map;
     114    concepts::WriteMap<Node,bool> processed_map;
     115   
     116    dfs_test
     117      .predMap(pred_map)
     118      .distMap(dist_map)
     119      .reachedMap(reached_map)
     120      .processedMap(processed_map);
    97121
    98122    dfs_test.run(s);
    99123    dfs_test.run(s,t);
    100124    dfs_test.run();
     125    dfs_test.init();
     126
     127    dfs_test.addSource(s);
     128    e = dfs_test.processNextArc();
     129    e = dfs_test.nextArc();
     130    b = dfs_test.emptyQueue();
     131    i = dfs_test.queueSize();
     132   
     133    dfs_test.start();
     134    dfs_test.start(t);
     135    dfs_test.start(am);
    101136
    102137    l  = dfs_test.dist(t);
  • test/dfs_test.cc

    r585 r959  
    5151  "@attributes\n"
    5252  "source 0\n"
    53   "target 5\n";
     53  "target 5\n"
     54  "source1 6\n"
     55  "target1 3\n";
     56
    5457
    5558void checkDfsCompile()
     
    180183  Digraph G;
    181184  Node s, t;
     185  Node s1, t1;
    182186
    183187  std::istringstream input(test_lgf);
     
    185189    node("source", s).
    186190    node("target", t).
     191    node("source1", s1).
     192    node("target1", t1).
    187193    run();
    188194
     
    211217
    212218  {
     219  Dfs<Digraph> dfs(G);
     220  check(dfs.run(s1,t1) && dfs.reached(t1),"Node 3 is reachable from Node 6.");
     221  }
     222 
     223  {
    213224    NullMap<Node,Arc> myPredMap;
    214225    dfs(G).predMap(myPredMap).run(s);
  • test/graph_copy_test.cc

    r890 r893  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • test/graph_copy_test.cc

    r440 r893  
    3030  const int nn = 10;
    3131
     32  // Build a digraph
    3233  SmartDigraph from;
    3334  SmartDigraph::NodeMap<int> fnm(from);
     
    5253  }
    5354
     55  // Test digraph copy
    5456  ListDigraph to;
    5557  ListDigraph::NodeMap<int> tnm(to);
     
    6971    nodeCrossRef(ncr).arcCrossRef(ecr).
    7072    node(fn, tn).arc(fa, ta).run();
     73 
     74  check(countNodes(from) == countNodes(to), "Wrong copy.");
     75  check(countArcs(from) == countArcs(to), "Wrong copy.");
    7176
    7277  for (SmartDigraph::NodeIt it(from); it != INVALID; ++it) {
     
    9196  check(tn == nr[fn], "Wrong copy.");
    9297  check(ta == er[fa], "Wrong copy.");
     98
     99  // Test repeated copy
     100  digraphCopy(from, to).run();
     101 
     102  check(countNodes(from) == countNodes(to), "Wrong copy.");
     103  check(countArcs(from) == countArcs(to), "Wrong copy.");
    93104}
    94105
     
    96107  const int nn = 10;
    97108
     109  // Build a graph
    98110  SmartGraph from;
    99111  SmartGraph::NodeMap<int> fnm(from);
     
    123135  }
    124136
     137  // Test graph copy
    125138  ListGraph to;
    126139  ListGraph::NodeMap<int> tnm(to);
     
    144157    nodeCrossRef(ncr).arcCrossRef(acr).edgeCrossRef(ecr).
    145158    node(fn, tn).arc(fa, ta).edge(fe, te).run();
     159
     160  check(countNodes(from) == countNodes(to), "Wrong copy.");
     161  check(countEdges(from) == countEdges(to), "Wrong copy.");
     162  check(countArcs(from) == countArcs(to), "Wrong copy.");
    146163
    147164  for (SmartGraph::NodeIt it(from); it != INVALID; ++it) {
     
    181198  check(ta == ar[fa], "Wrong copy.");
    182199  check(te == er[fe], "Wrong copy.");
     200
     201  // Test repeated copy
     202  graphCopy(from, to).run();
     203 
     204  check(countNodes(from) == countNodes(to), "Wrong copy.");
     205  check(countEdges(from) == countEdges(to), "Wrong copy.");
     206  check(countArcs(from) == countArcs(to), "Wrong copy.");
    183207}
    184208
Note: See TracChangeset for help on using the changeset viewer.