Changeset 544 for library/tests
- Timestamp:
- 08/18/09 08:34:25 (15 years ago)
- Location:
- library/tests
- Files:
-
- 1 added
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
library/tests/user_info_test.cpp
r542 r544 1 1 #include <string> 2 #include <vector> 2 3 #include <string.h> 3 4 #include "base/user_info.h" … … 76 77 string manufacturer; 77 78 78 Transport() { 79 year = 1900; 80 manufacturer = "unknown"; 81 } 82 83 Transport ( int year, string manufacturer ) 84 : year ( year ), manufacturer ( manufacturer ) { 79 Transport() : year( 1900 ), manufacturer( "unknown" ) { 80 } 81 82 Transport ( int year, string manufacturer ) : 83 year ( year ), manufacturer ( manufacturer ) { 85 84 } 86 85 … … 189 188 UIREGISTER ( Bike ); 190 189 190 class Teleport : public Transport { 191 public: 192 void to_setting ( Setting &set ) const { 193 set.add ( "this throws", Setting::TypeNone ); 194 } 195 }; 196 197 UIREGISTER ( Teleport ); 198 191 199 TEST ( test_load ) { 192 200 UIFile in ( "test_user_info_input.cfg" ); … … 205 213 shared_ptr<Transport> kati ( UI::build<Transport> ( in, "kati", UI::compulsory ) ); 206 214 CHECK_EQUAL ( string ( "A car made in 1980 by vecernicek, having 250000 kilometers on the clock." ), kati->to_string() ); 215 } 216 217 TEST ( test_load_error ) { 218 UIFile in ( "test_user_info_input.cfg" ); 219 220 try { 221 shared_ptr<Robot> failing ( UI::build<Robot> ( in, "elisky", UI::compulsory ) ); 222 CHECK ( false ); 223 } catch ( UIClassException &exc ) { 224 CHECK ( exc.what() ); 225 } 207 226 208 227 try { … … 210 229 CHECK ( false ); 211 230 } catch ( UIException &exc ) { 231 CHECK ( exc.what() ); 232 } 233 234 UIFile erroneous ( "erroneous.cfg" ); 235 try { 236 shared_ptr<Transport> jardovo ( UI::build<Transport> ( erroneous, "jardovo", UI::compulsory ) ); 237 CHECK ( false ); 238 } catch ( UISettingException &exc ) { 212 239 CHECK ( exc.what() ); 213 240 } … … 233 260 CHECK_EQUAL ( expected, actual ); 234 261 } 262 263 TEST ( test_save_error ) { 264 UIFile out; 265 266 Teleport teleport; 267 try { 268 UI::save ( &teleport, out, "unsaveable" ); 269 CHECK ( false ); 270 } catch ( UIException &exc ) { 271 CHECK ( exc.what() ); 272 } 273 }