Ignore:
Timestamp:
Apr 22, 2010, 2:57:13 AM (12 years ago)
Author:
Peter
Message:

extend load functions to work also for T=std::string

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/utility_test.cc

    r2239 r2248  
    4747void test_errno_error_func(void);
    4848void test_get_map(test::Suite&);
     49void test_load(test::Suite&);
    4950void test_inverse(test::Suite&);
    5051
     
    170171  test_errno_error(suite);
    171172  test_ptr_compare(suite);
     173  test_load(suite);
    172174
    173175  return suite.return_value();
     
    233235  if (!post_ok && prior_ok)
    234236    suite.err() << "test_less_nan failed\n";
     237}
     238
     239
     240void test_load(test::Suite& suite)
     241{
     242  std::istringstream iss(std::string("1.69 3.14"));
     243  std::vector<double> double_vec;
     244  utility::load(iss, double_vec);
     245  suite.add(double_vec.size()==2);
     246
     247  std::istringstream iss2(std::string("1 2"));
     248  std::vector<double> uint_vec;
     249  utility::load(iss2, uint_vec);
     250  suite.add(uint_vec.size()==2);
     251
     252  std::istringstream iss3(std::string("1.69 3.14"));
     253  std::vector<std::string> str_vec;
     254  utility::load(iss3, str_vec);
     255  if (str_vec.size()==2) {
     256    if (str_vec[1]!="3.14") {
     257      suite.out() << "error: load<string>:" << "\n"
     258                  << "  str_vec[1] = " << str_vec[1] << "\n"
     259                  << "  expected:  3.14n";
     260      suite.add(false);
     261    }
     262  }
     263  else {
     264    suite.out() << "str_vec.size() is not 2\n";
     265    suite.add(false);
     266  }
    235267}
    236268
Note: See TracChangeset for help on using the changeset viewer.