| 342 | |
| 343 | template<typename Stringy> |
| 344 | void self_assignment() |
| 345 | { |
| 346 | std::string str{"hello world"}; |
| 347 | Stringy str1{str}; |
| 348 | |
| 349 | expect(std::strcmp(str1.c_str(), str.c_str()) == 0); //this line is not really necessary, but why not, may as well test. |
| 350 | Stringy& str2 = str1; |
| 351 | str1 = str2; //self copy assignment |
| 352 | expect(std::strcmp(str1.c_str(), str.c_str()) == 0); //we're testing that nothing has been deleted or messed up |
| 353 | str2 = std::move(str1); //self move assignment |
| 354 | expect(std::strcmp(str2.c_str(), str.c_str()) == 0); //we're testing that nothing has been deleted or messed up |
| 355 | } |
| 356 | |
| 357 | test test_self_assignment = [] { |
| 358 | self_assignment<te::poly<IStringy, te::non_owning_storage>>(); |