COIN-OR::LEMON - Graph Library

Changeset 727:aada518af30f in lemon-0.x for src/test


Ignore:
Timestamp:
07/22/04 16:21:46 (20 years ago)
Author:
Alpar Juttner
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@982
Message:
  • Better Makefile.am. (I hope.)
  • Some more tests
Location:
src/test
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • src/test/Makefile.am

    r567 r727  
    11AM_CPPFLAGS = -I$(top_srcdir)/src
    22
    3 check_PROGRAMS = graph_test dijkstra_test time_measure_test
     3noinst_HEADERS = test_tools.h
     4
     5check_PROGRAMS = graph_test dijkstra_test time_measure_test error_test xy_test \
     6        test_tools_pass test_tools_fail
    47
    58TESTS = $(check_PROGRAMS)
    6 XFAIL_TESTS =
     9XFAIL_TESTS = test_tools_fail
    710
    8 graph_test_SOURCES = graph_test.cc test_tools.h
    9 dijkstra_test_SOURCES = dijkstra_test.cc test_tools.h
     11graph_test_SOURCES = graph_test.cc
     12dijkstra_test_SOURCES = dijkstra_test.cc
    1013time_measure_test_SOURCES = time_measure_test.cc
     14error_test_SOURCES = error_test.cc
     15xy_test_SOURCES = xy_test.cc
     16test_tools_pass_SOURCES = test_tools_pass.cc
     17test_tools_fail_SOURCES = test_tools_fail.cc
     18
  • src/test/error_test.cc

    r542 r727  
    22
    33#include <hugo/error.h>
    4 
     4#include "test_tools.h"
    55using namespace hugo;
    66using std::cout;
     
    2222
    2323int main() {
    24   bool no_errors = false;
    25 
    2624  try {
    27     cout << "Trying a faulty function\n";
    2825    faulty_fn();
    29     no_errors = true;
    30     cout << "FAILED!\n";
     26    check(false, "A faulty function did not fail.");
    3127  }
    3228  catch(const Exception &e) {
    33     cout << "E: " << e.what() << endl;
     29    cout << "Exeption = \"" << e.what() << "\" (Right behaviour)" << endl;
    3430  }
    3531
    3632  try {
    37     cout << "Trying a function throwing Exception\n";
    3833    exception_fn();
    39     no_errors = true;
    40     cout << "FAILED!\n";
     34    check(false, "The function did not throw Exception.");
    4135  }
    4236  catch(const Exception &e) {
    43     cout << "E: " << e.what() << endl;
     37    cout << "Exeption = \"" << e.what() << "\" (Right behaviour)" << endl;
    4438  }
    4539
    4640  try {
    47     cout << "Trying a function using FIXME\n";
    4841    unfinished_fn();
    49     no_errors = true;
    50     cout << "FAILED!\n";
     42    check(false, "FIXME macro does not work.");
    5143  }
    5244  catch(const Exception &e) {
    53     cout << "E: " << e.what() << endl;
     45    cout << "Exeption = \"" << e.what() << "\" (Right behaviour)" << endl;
    5446  }
    5547
    56   return no_errors ? 1 : 0;
     48  return 0;
    5749}
  • src/test/xy_test.cc

    r542 r727  
    11#include <hugo/xy.h>
    22#include <iostream>
     3#include "test_tools.h"
     4
    35using namespace std;
    46using namespace hugo;
    5 
    6 bool passed = true;
    7 
    8 void check(bool rc, char *msg="") {
    9   passed = passed && rc;
    10   if(!rc) {
    11     std::cerr << "Test failed! ("<< msg << ")" << std::endl; \
    12  
    13 
    14   }
    15 }
    16 
    17 
    18 
    197int main()
    208{
     
    2917
    3018        seged = a+b;
    31         check(seged.x==4 && seged.y==6);
     19        check(seged.x==4 && seged.y==6, "Wrong vector addition");
    3220
    3321        seged = a-b;
    3422        check(seged.x==-2 && seged.y==-2, "a-b");
    3523
    36         check(a.normSquare()==5);
     24        check(a.normSquare()==5,"Wrong norm calculation");
    3725        check(a*b==11, "a*b");
    3826
     
    5947
    6048        seged.x=2;seged.y=3;
    61         check(doboz1.inside(seged),"Inside? Should be.");
     49        check(doboz1.inside(seged),"Inside? It should be.");
    6250
    6351        seged.x=1;seged.y=3;
    64         check(doboz1.inside(seged),"Inside? Should be.");
     52        check(doboz1.inside(seged),"Inside? It should be.");
    6553
    6654        seged.x=0;seged.y=3;
    67         check(!doboz1.inside(seged),"Inside? Should not be.");
     55        check(!doboz1.inside(seged),"Inside? It should not be.");
    6856
    6957        BB doboz2(seged);
    70         check(!doboz2.empty(), "empty? Should not be. Constructed from 1 point.");
     58        check(!doboz2.empty(),
     59              "empty? Should not be. Constructed from 1 point.");
    7160
    7261        doboz2 += doboz1;
    73         check(doboz2.inside(seged),"Inside? Should be. Incremented a box with an other.");
    74 
    75         cout << (passed ? "All tests passed." : "Some of the tests failed!!!")
    76              << endl;
    77 
    78         return passed ? 0 : 1;
    79 
     62        check(doboz2.inside(seged),
     63              "Not inside? It should be. Incremented a box with an other.");
    8064}
Note: See TracChangeset for help on using the changeset viewer.