Ignore:
Timestamp:
Jan 15, 2009, 3:32:36 PM (12 years ago)
Author:
Jari Häkkinen
Message:

Fixes #466. GSL_error is now thrown on GSL errors. Last thing in this ticket.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/interpolation_test.cc

    r1666 r1724  
    22
    33/*
    4   Copyright (C) 2008 Jari Häkkinen
     4  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
     5  Copyright (C) 2009 Jari Häkkinen
    56
    67  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    2829#include "yat/regression/LinearInterpolation.h"
    2930#include "yat/regression/PolynomialInterpolation.h"
     31#include "yat/utility/Exception.h"
    3032#include "yat/utility/Vector.h"
    3133#include "yat/utility/VectorConstView.h"
     
    4143
    4244  test::Suite suite(argc, argv);
     45  suite.err() << "testing interpolations ..." << std::endl;
     46
    4347  test_delete(suite);
    4448
     
    5761  */
    5862
     63  suite.err() << "testing cspline" << std::endl;
    5964  utility::Vector x(6);
    6065  utility::Vector y(6);
     
    8590      suite.add(false);
    8691    }
    87     // Check for errors
    88     if (cspline.error_status()) {
    89       suite.err() << "cspline test failed with GSL_EDOM error" << std::endl;
    90       suite.add(false);
    91     }
    9292  }
    9393
     94  suite.err() << "testing exceptions" << std::endl;
    9495  // An error should be generated, if not test fails
    95   cspline.evaluate(w(0)-5);
    96   if (!cspline.error_status()) {
    97     suite.err() << "cspline test failed no GSL_EDOM error occured" << std::endl;
    98     suite.add(false);
     96  try {
     97    cspline.evaluate(w(0)-5); // expect GSL_error to be thrown
     98    suite.add(false); // this line is only executed if no error occured above
     99  }
     100  catch (utility::GSL_error) {
     101    // just catch the error, all is fine since the error is expected.
    99102  }
    100103
    101104  // lazy testing, at least try to create the objects
     105  suite.err() << "testing construction of\n"
     106              << "\tAkima, AkimaPeriodic, CSplinePeriodic, Linear, Polynomial"
     107              << std::endl;
    102108  AkimaInterpolation(x,y);
    103109  AkimaPeriodicInterpolation(x,y);
     
    111117void test_delete(test::Suite& suite)
    112118{
     119  suite.err() << "testing destruction" << std::endl;
    113120  utility::Vector x(10);
    114121  for (size_t i=0; i<x.size(); ++i)
Note: See TracChangeset for help on using the changeset viewer.