Changeset 2273
- Timestamp:
- Jun 15, 2010, 4:11:47 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/utility_test.cc
r2248 r2273 48 48 void test_get_map(test::Suite&); 49 49 void test_load(test::Suite&); 50 void test_load2(test::Suite&); 50 51 void test_inverse(test::Suite&); 51 52 … … 172 173 test_ptr_compare(suite); 173 174 test_load(suite); 175 test_load2(suite); 174 176 175 177 return suite.return_value(); … … 220 222 void test_less_nan(test::Suite& suite) 221 223 { 224 suite.out() << "test less_nan\n"; 222 225 bool prior_ok=suite.ok(); 223 226 utility::less_nan<double> f; … … 265 268 suite.add(false); 266 269 } 270 } 271 272 273 void 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); 267 292 } 268 293 -
trunk/yat/utility/utility.h
r2270 r2273 288 288 if (line.empty() && ignore_empty) 289 289 continue; 290 matrix. resize(matrix.size()+1);291 std::vector< double>& v=matrix.back();290 matrix.push_back(std::vector<T>()); 291 std::vector<T>& v=matrix.back(); 292 292 v.reserve(nof_columns); 293 293 std::stringstream ss(line); 294 294 load(ss, v, sep); 295 // add NaN for final separator 295 // add NaN for final separator (or empty string if T=std::string) 296 detail::VectorPusher<T> pusher; 296 297 if(sep!='\0' && !line.empty() && line[line.size()-1]==sep) 297 v.push_back(std::numeric_limits<T>::quiet_NaN());298 pusher("", v); 298 299 299 300 if (rectangle && nof_columns && v.size()!=nof_columns) { … … 324 325 if(!ok) 325 326 break; 326 327 327 pusher(element, vec); 328 328 }
Note: See TracChangeset
for help on using the changeset viewer.