Ignore:
Timestamp:
Aug 25, 2006, 2:59:21 PM (15 years ago)
Author:
Markus Ringnér
Message:

Fixed std includes to compile with g++ 4.1.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/data_lookup_1d_test.cc

    r565 r593  
    88#include <iostream>
    99#include <vector>
     10#include <cmath>
    1011
    1112using namespace theplu;
     
    3940  index_even.push_back(4);
    4041  classifier::MatrixLookup m1(gsl_m1,index_odd,index_even);
     42  *error << gsl_m1 << std::endl << '\n';
     43  *error << m1 << std::endl;
    4144  *error << "DataLookup1D::DataLookup1D(const MatrixLookup&\n"
    4245         << "                           const size_t, const bool)...";
     
    9396    *error << "Ok" << std::endl;
    9497
     98  *error << "Testing that output from ostream operator for DataLookup1D"
     99         << " can be used by the gslapi::vector istream constructor...";
     100
     101  // First with a vector with no missing values separated by ' '.
     102  std::ofstream my_out("data/tmp_test_datalookup1D.txt");
     103  my_out << v1;
     104  my_out.close();
     105  std::ifstream is("data/tmp_test_datalookup1D.txt");
     106  gslapi::vector v5(is);
     107  is.close();
     108  if (v5.size()!=v1.size() || v5(0)!=v1(0) || v5(1)!=v1(1) ||
     109      v5(2)!=v1(2)) {
     110    ok=false;
     111    *error << "\nERROR\n" << std::endl;
     112  }
     113  unlink("data/tmp_test_datalookup1D.txt");
     114 
     115  // Second with a vector with a missing value separated by '\t'.
     116  gsl_m1(3,0)=std::numeric_limits<double>::quiet_NaN();
     117  classifier::DataLookup1D v6(m1,1, true); 
     118  my_out.open("data/tmp_test_datalookup1D.txt");
     119  char prev=my_out.fill('\t');
     120  my_out << v1;
     121  my_out.fill(prev);
     122  my_out.close();
     123  is.open("data/tmp_test_datalookup1D.txt");
     124  gslapi::vector v7(is,'\t');
     125  is.close();
     126  if (v7.size()!=v6.size() || !std::isnan(v7(1))) {
     127    ok=false;
     128    *error << "\nERROR\n"
     129           << "size: " << v7.size() << " expected " << v6.size() << "\n"
     130           << "v7(1): " << v7(1) << " expected nan\n"
     131           << std::endl;
     132  }
     133  unlink("data/tmp_test_datalookup1D.txt");
     134   
     135
    95136  if (ok)
    96137    *error << "Ok." << std::endl;
Note: See TracChangeset for help on using the changeset viewer.