Ignore:
Timestamp:
Jun 15, 2010, 4:11:47 AM (12 years ago)
Author:
Peter
Message:

adding a test for load function (T=string) and fixed a bug in same function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/utility_test.cc

    r2248 r2273  
    4848void test_get_map(test::Suite&);
    4949void test_load(test::Suite&);
     50void test_load2(test::Suite&);
    5051void test_inverse(test::Suite&);
    5152
     
    172173  test_ptr_compare(suite);
    173174  test_load(suite);
     175  test_load2(suite);
    174176
    175177  return suite.return_value();
     
    220222void test_less_nan(test::Suite& suite)
    221223{
     224  suite.out() << "test less_nan\n";
    222225  bool prior_ok=suite.ok();
    223226  utility::less_nan<double> f;
     
    265268    suite.add(false);
    266269  }
     270}
     271
     272
     273void test_load2(test::Suite& suite)
     274{
     275  suite.out() << "test load<double>(matrix)\n";
     276  std::string str("1.69 3.14\n1.23 1.22\n");
     277  std::istringstream iss(str);
     278  std::vector<std::vector<double> > double_m;
     279  utility::load(iss, double_m);
     280  suite.add(double_m.size()==2);
     281
     282  suite.out() << "test load<std::string>(matrix)\n";
     283  suite.out() << str;
     284  std::istringstream iss2(str);
     285  std::vector<std::vector<std::string> > str_m;
     286  utility::load(iss2, str_m);
     287  std::cout << str_m.size() << std::endl;
     288  for (size_t i=0; i<str_m.size(); ++i)
     289    for (size_t j=0; j<str_m[i].size(); ++j)
     290      suite.out() << str_m[i][j] << "\n";
     291  suite.add(str_m.size()==2);
    267292}
    268293
Note: See TracChangeset for help on using the changeset viewer.